aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-09-01 01:31:38 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-09-04 17:22:33 -0400
commitc58b43218c1a04a0bcf338ea47406c759ac28e11 (patch)
treee13e33f195a13b4c959494ee7d059b87c2167be3 /kernel
parent8e254c1d183f0225ad21f9049641529e56cce4da (diff)
tracing/filters: Defer pred allocation, fix memory leak
The predicates of an event and their filter structure are allocated when we create an event filter for the first time. These objects must be created once but each time we come with a new filter, we overwrite such pre-existing allocation, if any. Thus, this patch checks if the filter has already been allocated before going ahead. Spotted-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Masami Hiramatsu <mhiramat@redhat.com> LKML-Reference: <4A9CB1BA.3060402@cn.fujitsu.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace_events_filter.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index c6b2edfb7fe9..93660fbbf629 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -409,6 +409,9 @@ static int init_preds(struct ftrace_event_call *call)
409 struct filter_pred *pred; 409 struct filter_pred *pred;
410 int i; 410 int i;
411 411
412 if (call->filter)
413 return 0;
414
412 filter = call->filter = kzalloc(sizeof(*filter), GFP_KERNEL); 415 filter = call->filter = kzalloc(sizeof(*filter), GFP_KERNEL);
413 if (!call->filter) 416 if (!call->filter)
414 return -ENOMEM; 417 return -ENOMEM;
@@ -447,11 +450,9 @@ static int init_subsystem_preds(struct event_subsystem *system)
447 if (strcmp(call->system, system->name) != 0) 450 if (strcmp(call->system, system->name) != 0)
448 continue; 451 continue;
449 452
450 if (!call->filter) { 453 err = init_preds(call);
451 err = init_preds(call); 454 if (err)
452 if (err) 455 return err;
453 return err;
454 }
455 } 456 }
456 457
457 return 0; 458 return 0;