aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/env.c
diff options
context:
space:
mode:
authorZhongqiu Han <[email protected]>2024-12-05 08:44:59 +0000
committerArnaldo Carvalho de Melo <[email protected]>2024-12-10 19:59:32 +0000
commita7da6c7030e1aec32f0a41c7b4fa70ec96042019 (patch)
tree3b25b136d3a9d8fdb89a5f44640b5f357220dffb /tools/perf/util/env.c
parentperf header: Fix one memory leakage in process_bpf_btf() (diff)
downloadkernel-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/env.c')
-rw-r--r--tools/perf/util/env.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index e890a52e01a6..2c5285718465 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -32,7 +32,7 @@ void perf_env__insert_bpf_prog_info(struct perf_env *env,
up_write(&env->bpf_progs.lock);
}
-void __perf_env__insert_bpf_prog_info(struct perf_env *env, struct bpf_prog_info_node *info_node)
+bool __perf_env__insert_bpf_prog_info(struct perf_env *env, struct bpf_prog_info_node *info_node)
{
__u32 prog_id = info_node->info_linear->info.id;
struct bpf_prog_info_node *node;
@@ -50,13 +50,14 @@ void __perf_env__insert_bpf_prog_info(struct perf_env *env, struct bpf_prog_info
p = &(*p)->rb_right;
} else {
pr_debug("duplicated bpf prog info %u\n", prog_id);
- return;
+ return false;
}
}
rb_link_node(&info_node->rb_node, parent, p);
rb_insert_color(&info_node->rb_node, &env->bpf_progs.infos);
env->bpf_progs.infos_cnt++;
+ return true;
}
struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env,