[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250617132442.9998-1-chenyuan_fl@163.com>
Date: Tue, 17 Jun 2025 09:24:42 -0400
From: Yuan Chen <chenyuan_fl@....com>
To: qmo@...nel.org,
ast@...nel.org
Cc: bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
andrii.nakryiko@...il.com,
chenyuan_fl@....com,
Yuan Chen <chenyuan@...inos.cn>
Subject: [PATCH v2] bpftool: Fix JSON writer resource leak in version command
From: Yuan Chen <chenyuan@...inos.cn>
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)
Signed-off-by: Yuan Chen <chenyuan@...inos.cn>
Suggested-by: Quentin Monnet <qmo@...nel.org>
---
tools/bpf/bpftool/main.c | 6 +++---
1 file 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);
--
2.44.0
Powered by blists - more mailing lists