Skip to content

Commit

Permalink
perf parse: Use YYABORT to clear stack after failure, plugging leaks
Browse files Browse the repository at this point in the history
Using return rather than YYABORT means that the stack isn't cleared up
following a failure. The change to YYABORT means the return value is 1
rather than -1, but the callers just check for a result of 0 (success).
Add missing free of a list when an error occurs in event_pmu.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20191109075840.181231-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Ian Rogers authored and Arnaldo Carvalho de Melo committed Nov 12, 2019
1 parent ccd2674 commit e1e9b78
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/perf/util/parse-events.y
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ PE_NAME opt_pmu_config
do { \
parse_events_terms__delete($2); \
parse_events_terms__delete(orig_terms); \
free(list); \
free($1); \
free(pattern); \
YYABORT; \
Expand Down Expand Up @@ -550,7 +551,7 @@ tracepoint_name opt_event_config
free($1.event);
if (err) {
free(list);
return -1;
YYABORT;
}
$$ = list;
}
Expand Down

0 comments on commit e1e9b78

Please sign in to comment.