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>
This commit is contained in:
parent
cfb180f3e7
commit
fe9f57f250
|
@ -24,26 +24,31 @@ int trace_define_field(struct ftrace_event_call *call, char *type,
|
||||||
{
|
{
|
||||||
struct ftrace_event_field *field;
|
struct ftrace_event_field *field;
|
||||||
|
|
||||||
field = kmalloc(sizeof(*field), GFP_KERNEL);
|
field = kzalloc(sizeof(*field), GFP_KERNEL);
|
||||||
if (!field)
|
if (!field)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
field->name = kstrdup(name, GFP_KERNEL);
|
field->name = kstrdup(name, GFP_KERNEL);
|
||||||
if (!field->name)
|
if (!field->name)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
field->type = kstrdup(type, GFP_KERNEL);
|
field->type = kstrdup(type, GFP_KERNEL);
|
||||||
if (!field->type)
|
if (!field->type)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
field->offset = offset;
|
field->offset = offset;
|
||||||
field->size = size;
|
field->size = size;
|
||||||
list_add(&field->link, &call->fields);
|
list_add(&field->link, &call->fields);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (field) {
|
if (field) {
|
||||||
kfree(field->name);
|
kfree(field->name);
|
||||||
kfree(field->type);
|
kfree(field->type);
|
||||||
}
|
}
|
||||||
kfree(field);
|
kfree(field);
|
||||||
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue