Skip to content

Commit a7f69d3

Browse files
chenyuan0001Kernel Patches Daemon
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) Signed-off-by: Yuan Chen <[email protected]> Suggested-by: Quentin Monnet <[email protected]> Reviewed-by: Quentin Monnet <[email protected]>
1 parent ca6e071 commit a7f69d3

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)