]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
tracing: add run-time field descriptions for event filtering, kfree fix
authorIngo Molnar <mingo@elte.hu>
Sun, 22 Mar 2009 17:41:59 +0000 (18:41 +0100)
committerIngo Molnar <mingo@elte.hu>
Sun, 22 Mar 2009 17:43:25 +0000 (18:43 +0100)
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>
kernel/trace/trace_events.c

index 97d4daaddd9a1b55ca5e1dc82e52d424d96d9796..594d78aaa1851e1663e73a66fae56afecd2eb14b 100644 (file)
@@ -24,26 +24,31 @@ int trace_define_field(struct ftrace_event_call *call, char *type,
 {
        struct ftrace_event_field *field;
 
-       field = kmalloc(sizeof(*field), GFP_KERNEL);
+       field = kzalloc(sizeof(*field), GFP_KERNEL);
        if (!field)
                goto err;
+
        field->name = kstrdup(name, GFP_KERNEL);
        if (!field->name)
                goto err;
+
        field->type = kstrdup(type, GFP_KERNEL);
        if (!field->type)
                goto err;
+
        field->offset = offset;
        field->size = size;
        list_add(&field->link, &call->fields);
 
        return 0;
+
 err:
        if (field) {
                kfree(field->name);
                kfree(field->type);
        }
        kfree(field);
+
        return -ENOMEM;
 }