From: Ian Rogers Date: Sun, 7 Nov 2021 09:00:02 +0000 (-0800) Subject: perf metric: Fix memory leaks X-Git-Tag: baikal/aarch64/sdk6.1~5362^2~2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=e47f5ed15934409e3bc1e0c6e3a56e76a4df3c12;p=kernel.git 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: 531381d0e6f1ceb5 ("perf metrics: Modify setup and deduplication") Signed-off-by: Ian Rogers Cc: Alexander Shishkin Cc: Jiri Olsa Cc: John Garry Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20211107090002.3784612-3-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 1b43cbc1961dd..fffe02aae3ed1 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)