Re: [PATCH v3] bpftool: Fix memory leak in dump_xx_nlmsg on realloc failure

From: Quentin Monnet
Date: Fri Jun 20 2025 - 05:01:17 EST


2025-06-20 09:21 UTC+0800 ~ Yuan Chen <chenyuan_fl@xxxxxxx>
> From: Yuan Chen <chenyuan@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>

Reviewed-by: Quentin Monnet <qmo@xxxxxxxxxx>

Thanks!