linux/tools/bpf/bpftool
Yuan Chen a7caec2a1b bpftool: Fix memory leak in dump_xx_nlmsg on realloc failure
[ Upstream commit 99fe8af069 ]

In function dump_xx_nlmsg(), when realloc() fails to allocate memory,
the original pointer to the buffer is overwritten with NULL. This causes
a memory leak because the previously allocated buffer becomes unreachable
without being freed.

Fixes: 7900efc192 ("tools/bpf: bpftool: improve output format for bpftool net")
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/r/20250620012133.14819-1-chenyuan_fl@163.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-08-28 16:24:07 +02:00
..
bash-completion tools: bpftool: Complete metrics list in "bpftool prog profile" doc 2021-07-30 15:40:28 -07:00
Documentation bpftool: Fix indent in option lists in the documentation 2022-01-27 11:05:26 +01:00
skeleton bpftool: Use a local bpf_perf_event_value to fix accessing its fields 2023-09-19 12:22:32 +02:00
.gitignore tools/bpf: Remove bpf-helpers from bpftool docs 2021-03-04 18:39:45 -08:00
btf.c tools: bpftool: Document and add bash completion for -L, -B options 2021-07-30 15:40:28 -07:00
btf_dumper.c bpftool: Fix a wrong type cast in btf_dumper_int 2022-10-26 12:34:39 +02:00
cfg.c tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
cfg.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00
cgroup.c tools: bpftool: Document and add bash completion for -L, -B options 2021-07-30 15:40:28 -07:00
common.c bpftool: Fix readlink usage in get_fd_type 2025-06-04 14:38:04 +02:00
feature.c bpftool: JIT limited misreported as negative value on aarch64 2023-07-23 13:46:50 +02:00
gen.c bpftool: Only set obj->skeleton on complete success 2022-04-08 14:23:24 +02:00
iter.c tools: bpftool: Update and synchronise option list in doc and help msg 2021-07-30 15:40:27 -07:00
jit_disasm.c bpftool: Remove asserts from JIT disassembler 2024-12-14 19:51:29 +01:00
json_writer.c tools: bpftool: Remove invalid \' json escape 2023-05-11 23:00:25 +09:00
json_writer.h bpftool: Support dumping metadata 2020-09-15 18:28:27 -07:00
link.c tools: bpftool: Update and synchronise option list in doc and help msg 2021-07-30 15:40:27 -07:00
main.c bpftool: Clear errno after libcap's checks 2022-10-26 12:35:32 +02:00
main.h bpftool: Remove asserts from JIT disassembler 2024-12-14 19:51:29 +01:00
Makefile tools bpftool: Fix compilation error with new binutils 2023-03-17 08:49:04 +01:00
map.c bpftool: Remove asserts from JIT disassembler 2024-12-14 19:51:29 +01:00
map_perf_ring.c tools, bpftool: Poison and replace kernel integer typedefs 2020-05-11 21:20:46 +02:00
net.c bpftool: Fix memory leak in dump_xx_nlmsg on realloc failure 2025-08-28 16:24:07 +02:00
netlink_dumper.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
netlink_dumper.h tools: bpftool: dual license all files 2018-12-13 12:08:44 +01:00
perf.c tools: bpftool: Update and synchronise option list in doc and help msg 2021-07-30 15:40:27 -07:00
pids.c tools/bpftool: Fix PID fetching with a lot of results 2020-12-08 16:45:20 +01:00
prog.c bpftool: fix potential NULL pointer dereferencing in prog_dump() 2024-12-14 19:51:29 +01:00
struct_ops.c tools: bpftool: Update and synchronise option list in doc and help msg 2021-07-30 15:40:27 -07:00
tracelog.c tools: bpftool: add an option to prevent auto-mount of bpffs, tracefs 2018-12-18 14:47:17 +01:00
xlated_dumper.c bpftool: Fix bug for long instructions in program CFG dumps 2023-05-11 23:00:27 +09:00
xlated_dumper.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00