ftrace: avoid duplicated function when writing set_graph_function
authorLiming Wang <liming.wang@windriver.com>
Thu, 4 Dec 2008 06:24:49 +0000 (14:24 +0800)
committerIngo Molnar <mingo@elte.hu>
Thu, 4 Dec 2008 08:42:35 +0000 (09:42 +0100)
Impact: fix a bug in function filter setting

when writing function to set_graph_function, we should check whether it
has existed in set_graph_function to avoid duplicating.

Signed-off-by: Liming Wang <liming.wang@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/ftrace.c

index eb57dc1ea097b2fc913afc83386a2c92c01698a6..d2b156538162bc5a51faa9a76a1fda4772f44cd9 100644 (file)
@@ -1425,7 +1425,7 @@ ftrace_set_func(unsigned long *array, int idx, char *buffer)
        struct dyn_ftrace *rec;
        struct ftrace_page *pg;
        int found = 0;
-       int i;
+       int i, j;
 
        if (ftrace_disabled)
                return -ENODEV;
@@ -1443,7 +1443,13 @@ ftrace_set_func(unsigned long *array, int idx, char *buffer)
                        kallsyms_lookup(rec->ip, NULL, NULL, NULL, str);
                        if (strcmp(str, buffer) == 0) {
                                found = 1;
-                               array[idx] = rec->ip;
+                               for (j = 0; j < idx; j++)
+                                       if (array[j] == rec->ip) {
+                                               found = 0;
+                                               break;
+                                       }
+                               if (found)
+                                       array[idx] = rec->ip;
                                break;
                        }
                }
This page took 0.027247 seconds and 5 git commands to generate.