diff options
| author | Zhongqiu Han <quic_zhonhan@quicinc.com> | 2024-12-05 16:44:58 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-08 09:52:05 +0100 |
| commit | 4f2582dacad498beb2759f4755d51860b862563a (patch) | |
| tree | e8d5da19aa162ac7dc1e7c19e31efb96a247e10c /tools | |
| parent | 3885a4d4a5195a6519fc8db5fc47f889503e2cfd (diff) | |
| download | linux-4f2582dacad498beb2759f4755d51860b862563a.tar.gz linux-4f2582dacad498beb2759f4755d51860b862563a.tar.bz2 linux-4f2582dacad498beb2759f4755d51860b862563a.zip | |
perf header: Fix one memory leakage in process_bpf_btf()
[ Upstream commit 875d22980a062521beed7b5df71fb13a1af15d83 ]
If __perf_env__insert_btf() returns false due to a duplicate btf node
insertion, the temporary node will leak. Add a check to ensure the memory
is freed if the function returns false.
Fixes: a70a1123174ab592 ("perf bpf: Save BTF information as headers to perf.data")
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20241205084500.823660-2-quic_zhonhan@quicinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/util/header.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 1482567e5ac1..34d3b567ae77 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3224,7 +3224,8 @@ static int process_bpf_btf(struct feat_fd *ff, void *data __maybe_unused) if (__do_read(ff, node->data, data_size)) goto out; - __perf_env__insert_btf(env, node); + if (!__perf_env__insert_btf(env, node)) + free(node); node = NULL; } |
