]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpftool: Fix memory leak in dump_xx_nlmsg on realloc failure
authorYuan Chen <chenyuan@kylinos.cn>
Fri, 20 Jun 2025 01:21:33 +0000 (09:21 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:08:45 +0000 (12:08 +0200)
commit0abd1f48cd25c8b397d4ee26c6c7e9d24b08ff70
treef041faa7780e0e9211406fe14fb3d7882ffbc1e5
parent0f18414f1d6b34d13ab1c41d688a8eb8d94c0e95
bpftool: Fix memory leak in dump_xx_nlmsg on realloc failure

[ Upstream commit 99fe8af069a9fa5b09140518b1364e35713a642e ]

In function dump_xx_nlmsg(), when realloc() fails to allocate memory,
the original pointer to the buffer is overwritten with NULL. This causes
a memory leak because the previously allocated buffer becomes unreachable
without being freed.

Fixes: 7900efc19214 ("tools/bpf: bpftool: improve output format for bpftool net")
Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/r/20250620012133.14819-1-chenyuan_fl@163.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/bpf/bpftool/net.c