diff options
author | Yicong Yang <yangyicong@hisilicon.com> | 2023-12-07 11:16:34 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-01-26 02:35:52 +0300 |
commit | f8d47ca6785ce0d5998b24ec3857649fb8e6f9f5 (patch) | |
tree | a79afcfb0d9d4a5b911f2a3928c64a21c3b3b67a /tools/perf | |
parent | 2c664df0b201916d76088bbf47c501e3b73ae060 (diff) | |
download | linux-f8d47ca6785ce0d5998b24ec3857649fb8e6f9f5.tar.xz |
perf header: Fix one memory leakage in perf_event__fprintf_event_update()
[ Upstream commit 813900d19b923fc1b241c1ce292472f68066092b ]
When dump the raw trace by `perf report -D` ASan reports a memory
leakage in perf_event__fprintf_event_update().
It shows that we allocated a temporary cpumap for dumping the CPUs but
doesn't release it and it's not used elsewhere. Fix this by free the
cpumap after the dumping.
Fixes: c853f9394b7bc189 ("perf tools: Add perf_event__fprintf_event_update function")
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Junhao He <hejunhao3@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linuxarm@huawei.com
Link: https://lore.kernel.org/r/20231207081635.8427-2-yangyicong@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/header.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 41032243774e..f6035c219b41 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -4363,9 +4363,10 @@ size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp) ret += fprintf(fp, "... "); map = cpu_map__new_data(&ev->cpus.cpus); - if (map) + if (map) { ret += cpu_map__fprintf(map, fp); - else + perf_cpu_map__put(map); + } else ret += fprintf(fp, "failed to get cpus\n"); break; default: |