Skip to content

Commit 9d88bc8

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: chenyuan <[email protected]>
1 parent 13e07b5 commit 9d88bc8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tools/bpf/bpftool/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ static int do_version(int argc, char **argv)
164164
jsonw_end_object(json_wtr); /* features */
165165

166166
jsonw_end_object(json_wtr); /* root object */
167+
jsonw_destroy(&json_wtr);
167168
} else {
168169
unsigned int nb_features = 0;
169170

0 commit comments

Comments
 (0)