From: Yuan Chen <chenyuan_fl@163.com>
To: qmo@kernel.org, ast@kernel.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
chenyuan_fl@163.com, chenyuan <chenyuan@kylinos.cn>
Subject: [PATCH] bpftool: Fix JSON writer resource leak in version command
Date: Mon, 16 Jun 2025 09:50:14 -0400 [thread overview]
Message-ID: <20250616135014.12327-1-chenyuan_fl@163.com> (raw)
From: chenyuan <chenyuan@kylinos.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@kylinos.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
next reply other threads:[~2025-06-16 13:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 13:50 Yuan Chen [this message]
2025-06-16 14:24 ` Quentin Monnet
2025-06-16 15:27 Yuan Chen
2025-06-16 15:50 ` Quentin Monnet
2025-06-16 21:19 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250616135014.12327-1-chenyuan_fl@163.com \
--to=chenyuan_fl@163.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyuan@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=qmo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®