[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250616135014.12327-1-chenyuan_fl@163.com>
Date: Mon, 16 Jun 2025 09:50:14 -0400
From: Yuan Chen <chenyuan_fl@....com>
To: qmo@...nel.org,
ast@...nel.org
Cc: bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
chenyuan_fl@....com,
chenyuan <chenyuan@...inos.cn>
Subject: [PATCH] bpftool: Fix JSON writer resource leak in version command
From: chenyuan <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: chenyuan <chenyuan@...inos.cn>
---
tools/bpf/bpftool/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index cd5963cb6058..c8838196a3bd 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -164,6 +164,7 @@ static int do_version(int argc, char **argv)
jsonw_end_object(json_wtr); /* features */
jsonw_end_object(json_wtr); /* root object */
+ jsonw_destroy(&json_wtr);
} else {
unsigned int nb_features = 0;
--
2.44.0
Powered by blists - more mailing lists