tools lib traceevent: Fix a possibly wrong memory dereference
authorNamhyung Kim <[email protected]>
Wed, 23 May 2012 02:36:49 +0000 (11:36 +0900)
committerArnaldo Carvalho de Melo <[email protected]>
Thu, 24 May 2012 14:33:34 +0000 (11:33 -0300)
If set_op_prio() failed, the token will be freed at out_free,
then arg->op.op would turn out to be a dangle pointer. After
returning EVENT_ERROR from process_op(), free_arg() will be
called and then it will finally see the dangling pointer.

Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/lib/traceevent/event-parse.c

index d598b376e3c1204a046790c41083949ffdd64140..445a43ad42fd74531e01831329f5290b59e9b0c3 100644 (file)
@@ -1715,6 +1715,8 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
 
                if (set_op_prio(arg) == -1) {
                        event->flags |= EVENT_FL_FAILED;
+                       /* arg->op.op (= token) will be freed at out_free */
+                       arg->op.op = NULL;
                        goto out_free;
                }