diff options
| author | Zhongqiu Han <[email protected]> | 2024-12-05 08:44:59 +0000 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <[email protected]> | 2024-12-10 19:59:32 +0000 |
| commit | a7da6c7030e1aec32f0a41c7b4fa70ec96042019 (patch) | |
| tree | 3b25b136d3a9d8fdb89a5f44640b5f357220dffb /tools/perf/util/header.c | |
| parent | perf header: Fix one memory leakage in process_bpf_btf() (diff) | |
| download | kernel-a7da6c7030e1aec32f0a41c7b4fa70ec96042019.tar.gz kernel-a7da6c7030e1aec32f0a41c7b4fa70ec96042019.zip | |
perf header: Fix one memory leakage in process_bpf_prog_info()
Function __perf_env__insert_bpf_prog_info() will return without inserting
bpf prog info node into perf env again due to a duplicate bpf prog info
node insertion, causing the temporary info_linear and info_node memory to
leak. Modify the return type of this function to bool and add a check to
ensure the memory is freed if the function returns false.
Fixes: 606f972b1361f477 ("perf bpf: Save bpf_prog_info information as headers to perf.data")
Reviewed-by: Namhyung Kim <[email protected]>
Signed-off-by: Zhongqiu Han <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: James Clark <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Yicong Yang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/perf/util/header.c')
| -rw-r--r-- | tools/perf/util/header.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index fbba6ffafec4..d06aa86352d3 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3158,7 +3158,10 @@ static int process_bpf_prog_info(struct feat_fd *ff, void *data __maybe_unused) /* after reading from file, translate offset to address */ bpil_offs_to_addr(info_linear); info_node->info_linear = info_linear; - __perf_env__insert_bpf_prog_info(env, info_node); + if (!__perf_env__insert_bpf_prog_info(env, info_node)) { + free(info_linear); + free(info_node); + } } up_write(&env->bpf_progs.lock); |
