* [PATCH v2] bpftool: Fix JSON writer resource leak in version command
@ 2025-06-17 13:24 Yuan Chen
2025-06-17 14:09 ` Quentin Monnet
2025-06-17 20:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Yuan Chen @ 2025-06-17 13:24 UTC (permalink / raw)
To: qmo, ast; +Cc: bpf, linux-kernel, andrii.nakryiko, chenyuan_fl, Yuan Chen
From: Yuan Chen <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: Yuan Chen <chenyuan@kylinos.cn>
Suggested-by: Quentin Monnet <qmo@kernel.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] bpftool: Fix JSON writer resource leak in version command
2025-06-17 13:24 [PATCH v2] bpftool: Fix JSON writer resource leak in version command Yuan Chen
@ 2025-06-17 14:09 ` Quentin Monnet
2025-06-17 20:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Quentin Monnet @ 2025-06-17 14:09 UTC (permalink / raw)
To: Yuan Chen, ast; +Cc: bpf, linux-kernel, andrii.nakryiko, Yuan Chen
2025-06-17 09:24 UTC-0400 ~ Yuan Chen <chenyuan_fl@163.com>
> From: Yuan Chen <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: Yuan Chen <chenyuan@kylinos.cn>
> Suggested-by: Quentin Monnet <qmo@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] bpftool: Fix JSON writer resource leak in version command
2025-06-17 13:24 [PATCH v2] bpftool: Fix JSON writer resource leak in version command Yuan Chen
2025-06-17 14:09 ` Quentin Monnet
@ 2025-06-17 20:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-17 20:30 UTC (permalink / raw)
To: Yuan Chen; +Cc: qmo, ast, bpf, linux-kernel, andrii.nakryiko, chenyuan
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Tue, 17 Jun 2025 09:24:42 -0400 you wrote:
> From: Yuan Chen <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.
>
> [...]
Here is the summary with links:
- [v2] bpftool: Fix JSON writer resource leak in version command
https://git.kernel.org/bpf/bpf-next/c/85cd83fed826
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-17 20:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 13:24 [PATCH v2] bpftool: Fix JSON writer resource leak in version command Yuan Chen
2025-06-17 14:09 ` Quentin Monnet
2025-06-17 20:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).