Skip to content

Commit

Permalink
perf metric: Fix some memory leaks - part 2
Browse files Browse the repository at this point in the history
The metric_event_delete() missed to free expr->metric_events and it
should free an expr when metric_refs allocation failed.

Fixes: 4ea2896 ("perf metric: Collect referenced metrics in struct metric_expr")
Signed-off-by: Namhyung Kim <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: John Garry <[email protected]>
Cc: Kajol Jain <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
namhyung authored and acmel committed Sep 15, 2020
1 parent 4f57a1e commit b033ab1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/perf/util/metricgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static void metric_event_delete(struct rblist *rblist __maybe_unused,

list_for_each_entry_safe(expr, tmp, &me->head, nd) {
free(expr->metric_refs);
free(expr->metric_events);
free(expr);
}

Expand Down Expand Up @@ -316,6 +317,7 @@ static int metricgroup__setup_events(struct list_head *groups,
if (!metric_refs) {
ret = -ENOMEM;
free(metric_events);
free(expr);
break;
}

Expand Down

0 comments on commit b033ab1

Please sign in to comment.