diff options
author | Ian Rogers <[email protected]> | 2021-11-07 01:00:02 -0800 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2021-11-07 15:39:28 -0300 |
commit | aba8c5e38075fa0e0a5463b73b0788f71bb4c78d (patch) | |
tree | 538f08e97f8dd72dc08933ac453f139ee4d7ef56 | |
parent | 07eafd4e053a41d72611848b8758df0752b53ee4 (diff) |
perf metric: Fix memory leaks
Certain error paths may leak memory as caught by address sanitizer.
Ensure this is cleaned up to make sure address/leak sanitizer is happy.
Fixes: 5ecd5a0c7d1cca79 ("perf metrics: Modify setup and deduplication")
Signed-off-by: Ian Rogers <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: John Garry <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[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]>
-rw-r--r-- | tools/perf/util/metricgroup.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 1b43cbc1961d..fffe02aae3ed 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -228,6 +228,7 @@ static void metric__free(struct metric *m) free(m->metric_refs); expr__ctx_free(m->pctx); free((char *)m->modifier); + evlist__delete(m->evlist); free(m); } @@ -1482,8 +1483,10 @@ static int parse_groups(struct evlist *perf_evlist, const char *str, } - if (combined_evlist) + if (combined_evlist) { evlist__splice_list_tail(perf_evlist, &combined_evlist->core.entries); + evlist__delete(combined_evlist); + } list_for_each_entry(m, &metric_list, nd) { if (m->evlist) |