Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.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/20211107090002.3784612-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
aba8c5e3 07eafd4e

+4 -1
+4 -1
tools/perf/util/metricgroup.c
··· 228 228 free(m->metric_refs); 229 229 expr__ctx_free(m->pctx); 230 230 free((char *)m->modifier); 231 + evlist__delete(m->evlist); 231 232 free(m); 232 233 } 233 234 ··· 1483 1482 } 1484 1483 1485 1484 1486 - if (combined_evlist) 1485 + if (combined_evlist) { 1487 1486 evlist__splice_list_tail(perf_evlist, &combined_evlist->core.entries); 1487 + evlist__delete(combined_evlist); 1488 + } 1488 1489 1489 1490 list_for_each_entry(m, &metric_list, nd) { 1490 1491 if (m->evlist)