linux/tools/bpf/bpftool
Yuan Chen 45218b8b22 bpftool: Fix JSON writer resource leak in version command
[ Upstream commit 85cd83fed8 ]

When using `bpftool --version -j/-p`, the JSON writer object
created in do_version() was not properly destroyed after use.
This caused a memory leak each time the version command was
executed with JSON output.

Fix: 004b45c0e5 (tools: bpftool: provide JSON output for all possible commands)

Suggested-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/bpf/20250617132442.9998-1-chenyuan_fl@163.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-08-20 18:30:38 +02:00
..
bash-completion bpftool: Add bash-completion for tcx subcommand 2024-07-29 12:54:04 -07:00
Documentation bpftool: Fix typos 2024-09-09 15:57:52 -07:00
skeleton bpftool: Fix typo in MAX_NUM_METRICS macro name 2024-06-03 16:58:27 +02:00
.gitignore bpftool: Fix SPDX tag for Makefiles and .gitignore 2021-11-10 09:00:52 -08:00
btf.c bpftool: Improve btf c dump sorting stability 2024-09-06 14:06:30 -07:00
btf_dumper.c bpftool: Fix printing of pointer value 2023-10-19 16:29:36 +02:00
cfg.c bpftool: Support printing opcodes and source file references in CFG 2023-04-05 21:27:27 -07:00
cfg.h bpftool: Support printing opcodes and source file references in CFG 2023-04-05 21:27:27 -07:00
cgroup.c bpftool: Fix cgroup command to only show cgroup bpf programs 2025-06-27 11:11:46 +01:00
common.c bpftool: Fix readlink usage in get_fd_type 2025-05-29 11:03:05 +02:00
feature.c bpftool: fix some typos in bpftool 2024-09-05 13:07:47 -07:00
gen.c bpftool: improve skeleton backwards compat with old buggy libbpfs 2024-07-09 19:03:05 -07:00
iter.c bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
jit_disasm.c bpf, bpftool: Fix incorrect disasm pc 2024-12-05 14:01:51 +01:00
json_writer.c tools: bpftool: json: Fix backslash escape typo in jsonw_puts 2023-03-29 09:48:45 -07:00
json_writer.h tools: bpftool: json: Fix backslash escape typo in jsonw_puts 2023-03-29 09:48:45 -07:00
link.c bpftool: Add link dump support for BPF_LINK_TYPE_SOCKMAP 2024-04-10 19:52:25 -07:00
main.c bpftool: Fix JSON writer resource leak in version command 2025-08-20 18:30:38 +02:00
main.h bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
Makefile bpftool: Fix make dependencies for vmlinux.h 2024-05-18 10:46:16 -07:00
map.c bpftool: Recognize arena map type 2024-03-11 15:37:24 -07:00
map_perf_ring.c bpftool: Fix error message of strerror 2022-09-30 15:40:46 -07:00
net.c bpftool: Fix memory leak in dump_xx_nlmsg on realloc failure 2025-08-15 12:13:40 +02:00
netlink_dumper.c bpftool: Use consistent include paths for libbpf 2020-01-20 16:37:45 -08:00
netlink_dumper.h bpftool: Extend net dump with tcx progs 2023-07-19 10:07:28 -07:00
perf.c bpftool: fix perf help message 2023-08-11 20:54:29 -07:00
pids.c bpftool: Enable libbpf logs when loading pid_iter in debug mode 2024-03-19 23:12:22 -07:00
prog.c bpf: bpftool: Setting error code in do_loader() 2025-05-02 07:59:16 +02:00
struct_ops.c bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
tracelog.c bpftool, musl compat: Replace sys/fcntl.h by fcntl.h 2022-04-25 23:24:28 +02:00
xlated_dumper.c tools/bpf: Fix the wrong format specifier 2024-07-30 13:41:20 -07:00
xlated_dumper.h bpftool: Dump the kernel symbol's module name 2023-07-11 20:07:50 -07:00