diff options
| author | 2024-12-05 16:45:00 +0800 | |
|---|---|---|
| committer | 2024-12-10 16:59:32 -0300 | |
| commit | 03edb7020bb920f1935c3f30acad0bb27fdb99af (patch) | |
| tree | b04c1708c6eee8cc98a10a69669f3efccb5dab5c /tools/perf/util/env.h | |
| parent | perf header: Fix one memory leakage in process_bpf_prog_info() (diff) | |
| download | wireguard-linux-03edb7020bb920f1935c3f30acad0bb27fdb99af.tar.xz wireguard-linux-03edb7020bb920f1935c3f30acad0bb27fdb99af.zip | |
perf bpf: Fix two memory leakages when calling perf_env__insert_bpf_prog_info()
If perf_env__insert_bpf_prog_info() returns false due to a duplicate bpf
prog info node insertion, the temporary info_node and info_linear memory
will leak. Add a check to ensure the memory is freed if the function
returns false.
Fixes: d56354dc49091e33 ("perf tools: Save bpf_prog_info and BTF of new BPF programs")
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-4-quic_zhonhan@quicinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/env.h')
| -rw-r--r-- | tools/perf/util/env.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index 9db2e5a625ed..da11add761d0 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -178,7 +178,7 @@ int perf_env__nr_cpus_avail(struct perf_env *env); void perf_env__init(struct perf_env *env); bool __perf_env__insert_bpf_prog_info(struct perf_env *env, struct bpf_prog_info_node *info_node); -void perf_env__insert_bpf_prog_info(struct perf_env *env, +bool perf_env__insert_bpf_prog_info(struct perf_env *env, struct bpf_prog_info_node *info_node); struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env, __u32 prog_id); |
