Skip to content

Commit 85cd83f

Browse files
chenyuan0001anakryiko
authored andcommitted
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: 004b45c (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]
1 parent 66ab68c commit 85cd83f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/bpf/bpftool/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,9 @@ int main(int argc, char **argv)
534534
usage();
535535

536536
if (version_requested)
537-
return do_version(argc, argv);
538-
539-
ret = cmd_select(commands, argc, argv, do_help);
537+
ret = do_version(argc, argv);
538+
else
539+
ret = cmd_select(commands, argc, argv, do_help);
540540

541541
if (json_output)
542542
jsonw_destroy(&json_wtr);

0 commit comments

Comments
 (0)