Skip to content

Commit 35eb30c

Browse files
rostedtgregkh
authored andcommitted
tools lib traceevent: Do not reassign parg after collapse_tree()
commit 106b816cb46ebd87408b4ed99a2e16203114daa6 upstream. At the end of process_filter(), collapse_tree() was changed to update the parg parameter, but the reassignment after the call wasn't removed. What happens is that the "current_op" gets modified and freed and parg is assigned to the new allocated argument. But after the call to collapse_tree(), parg is assigned again to the just freed "current_op", and this causes the tool to crash. The current_op variable must also be assigned to NULL in case of error, otherwise it will cause it to be free()ed twice. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Fixes: 42d6194 ("tools lib traceevent: Refactor process_filter()") Link: http://lkml.kernel.org/r/20160511150936.678c18a1@gandalf.local.home Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4c127a3 commit 35eb30c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tools/lib/traceevent/parse-filter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,11 +1164,11 @@ process_filter(struct event_format *event, struct filter_arg **parg,
11641164
current_op = current_exp;
11651165

11661166
ret = collapse_tree(current_op, parg, error_str);
1167+
/* collapse_tree() may free current_op, and updates parg accordingly */
1168+
current_op = NULL;
11671169
if (ret < 0)
11681170
goto fail;
11691171

1170-
*parg = current_op;
1171-
11721172
free(token);
11731173
return 0;
11741174

0 commit comments

Comments
 (0)