aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_events.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-03-22 13:41:59 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-22 13:43:25 -0400
commitfe9f57f250ab4d781b99504caeb218ca2db14c1a (patch)
treedc2452c3a9eb2f7cb220270e4ee0de132db6bb50 /kernel/trace/trace_events.c
parentcfb180f3e71b2a280a254c8646a9ab1beab63f84 (diff)
tracing: add run-time field descriptions for event filtering, kfree fix
Impact: fix potential kfree of random data in (rare) failure path Zero-initialize the field structure. Reported-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <1237710639.7703.46.camel@charm-linux> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace_events.c')
-rw-r--r--kernel/trace/trace_events.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 97d4daaddd9a..594d78aaa185 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -24,26 +24,31 @@ int trace_define_field(struct ftrace_event_call *call, char *type,
24{ 24{
25 struct ftrace_event_field *field; 25 struct ftrace_event_field *field;
26 26
27 field = kmalloc(sizeof(*field), GFP_KERNEL); 27 field = kzalloc(sizeof(*field), GFP_KERNEL);
28 if (!field) 28 if (!field)
29 goto err; 29 goto err;
30
30 field->name = kstrdup(name, GFP_KERNEL); 31 field->name = kstrdup(name, GFP_KERNEL);
31 if (!field->name) 32 if (!field->name)
32 goto err; 33 goto err;
34
33 field->type = kstrdup(type, GFP_KERNEL); 35 field->type = kstrdup(type, GFP_KERNEL);
34 if (!field->type) 36 if (!field->type)
35 goto err; 37 goto err;
38
36 field->offset = offset; 39 field->offset = offset;
37 field->size = size; 40 field->size = size;
38 list_add(&field->link, &call->fields); 41 list_add(&field->link, &call->fields);
39 42
40 return 0; 43 return 0;
44
41err: 45err:
42 if (field) { 46 if (field) {
43 kfree(field->name); 47 kfree(field->name);
44 kfree(field->type); 48 kfree(field->type);
45 } 49 }
46 kfree(field); 50 kfree(field);
51
47 return -ENOMEM; 52 return -ENOMEM;
48} 53}
49 54