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

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>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
e4e29079 4e88118c

+1
+1
tools/perf/util/stat-shadow.c
··· 444 444 "Add %s event to groups to get metric expression for %s\n", 445 445 metric_name, 446 446 counter->name); 447 + free(printed); 447 448 printed = strdup(metric_name); 448 449 } 449 450 invalid = true;