Skip to content

Commit

Permalink
tools lib traceevent: Fix error path on pevent_parse_event
Browse files Browse the repository at this point in the history
If __pevent_parse_format() succeeded but add_event() failed, 'ret' didn't
have a proper error code.  Set it to PEVENT_ERRNO__MEM_ALLOC_FAILED.

In addition, at that point 'event' also has fields and format
information and they all need to be freed.  Call pevent_free_format() to
handle it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1348575919-4954-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Sep 25, 2012
1 parent af9da88 commit f1b2256
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -5044,8 +5044,10 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
/* Add pevent to event so that it can be referenced */
event->pevent = pevent;

if (add_event(pevent, event))
if (add_event(pevent, event)) {
ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
goto event_add_failed;
}

#define PRINT_ARGS 0
if (PRINT_ARGS && event->print_fmt.args)
Expand All @@ -5054,9 +5056,7 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
return 0;

event_add_failed:
free(event->system);
free(event->name);
free(event);
pevent_free_format(event);
return ret;
}

Expand Down

0 comments on commit f1b2256

Please sign in to comment.