aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Chen <[email protected]>2025-06-17 13:24:42 +0000
committerAndrii Nakryiko <[email protected]>2025-06-17 20:28:26 +0000
commit85cd83fed8267cde0dd1cea719808aad95ae4de7 (patch)
tree45fda4624875530fc8bc362a1084a38edf955eb7
parentselftests/bpf: Fix unintentional switch case fall through (diff)
downloadkernel-85cd83fed8267cde0dd1cea719808aad95ae4de7.tar.gz
kernel-85cd83fed8267cde0dd1cea719808aad95ae4de7.zip
bpftool: Fix JSON writer resource leak in version command
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: 004b45c0e51a (tools: bpftool: provide JSON output for all possible commands) Suggested-by: Quentin Monnet <[email protected]> Signed-off-by: Yuan Chen <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Reviewed-by: Quentin Monnet <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
-rw-r--r--tools/bpf/bpftool/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index cd5963cb6058..2b7f2bd3a7db 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -534,9 +534,9 @@ int main(int argc, char **argv)
usage();
if (version_requested)
- return do_version(argc, argv);
-
- ret = cmd_select(commands, argc, argv, do_help);
+ ret = do_version(argc, argv);
+ else
+ ret = cmd_select(commands, argc, argv, do_help);
if (json_output)
jsonw_destroy(&json_wtr);