tools lib traceevent: Do not link broken field arg for an old ftrace event
authorNamhyung Kim <[email protected]>
Wed, 22 Aug 2012 07:00:28 +0000 (16:00 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Wed, 22 Aug 2012 19:02:36 +0000 (16:02 -0300)
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: Namhyung Kim <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/lib/traceevent/event-parse.c

index b7c2c491f61eb1ddf03a1c5c1b6807e8452d7be3..33fcd943f096741ad2968ea6150876f9f6400930 100644 (file)
@@ -4754,20 +4754,20 @@ int pevent_parse_event(struct pevent *pevent,
                struct print_arg *arg, **list;
 
                /* old ftrace had no args */
-
                list = &event->print_fmt.args;
                for (field = event->format.fields; field; field = field->next) {
                        arg = alloc_arg();
-                       *list = arg;
-                       list = &arg->next;
                        arg->type = PRINT_FIELD;
                        arg->field.name = strdup(field->name);
                        if (!arg->field.name) {
                                do_warning("failed to allocate field name");
                                event->flags |= EVENT_FL_FAILED;
+                               free_arg(arg);
                                return -1;
                        }
                        arg->field.field = field;
+                       *list = arg;
+                       list = &arg->next;
                }
                return 0;
        }