Commit fd34f0b2 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

tools lib traceevent: Do not link broken field arg for an old ftrace event

Defer linking a newly allocated arg to print_fmt.args until all of its
field is setup so that later access to ->field.name cannot be NULL.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1345618831-9148-2-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 1659d129
...@@ -4754,20 +4754,20 @@ int pevent_parse_event(struct pevent *pevent, ...@@ -4754,20 +4754,20 @@ int pevent_parse_event(struct pevent *pevent,
struct print_arg *arg, **list; struct print_arg *arg, **list;
/* old ftrace had no args */ /* old ftrace had no args */
list = &event->print_fmt.args; list = &event->print_fmt.args;
for (field = event->format.fields; field; field = field->next) { for (field = event->format.fields; field; field = field->next) {
arg = alloc_arg(); arg = alloc_arg();
*list = arg;
list = &arg->next;
arg->type = PRINT_FIELD; arg->type = PRINT_FIELD;
arg->field.name = strdup(field->name); arg->field.name = strdup(field->name);
if (!arg->field.name) { if (!arg->field.name) {
do_warning("failed to allocate field name"); do_warning("failed to allocate field name");
event->flags |= EVENT_FL_FAILED; event->flags |= EVENT_FL_FAILED;
free_arg(arg);
return -1; return -1;
} }
arg->field.field = field; arg->field.field = field;
*list = arg;
list = &arg->next;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment