summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2021-11-07 01:54:44 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-11-07 12:44:53 -0300
commite4e290791d87b95b2b1fa991e504fba89cbe2a03 (patch)
treebc776ad604f8cd3c5cf14cec89425d0429c5fb26 /tools/perf/util
parent4e88118c20fc5fa7890230da2d26f0235dd904f5 (diff)
downloadlinux-e4e290791d87b95b2b1fa991e504fba89cbe2a03.tar.bz2
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 <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/20211107085444.3781604-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/stat-shadow.c1
1 files changed, 1 insertions, 0 deletions
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;