From e4e290791d87b95b2b1fa991e504fba89cbe2a03 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Sun, 7 Nov 2021 01:54:44 -0700 Subject: perf stat: Fix memory leak on error path strdup() is used to deduplicate, ensure it isn't leaking an already created string by freeing first. 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/20211107085444.3781604-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat-shadow.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/perf/util') diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 69f3cf3b4a44..e4fb02b05130 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -444,6 +444,7 @@ void perf_stat__collect_metric_expr(struct evlist *evsel_list) "Add %s event to groups to get metric expression for %s\n", metric_name, counter->name); + free(printed); printed = strdup(metric_name); } invalid = true; -- cgit v1.2.3