libbpf: fix memleak in libbpf_netlink_recv()
Andrii Nakryiko
maintainerPATCH 1/1 libbpf: fix memleak in libbpf_netlink_recv()
Ensure that libbpf_netlink_recv() frees dynamically allocated buffer in all code paths.
Cc Toke Høiland-Jørgensen <[email protected]>
Fixes 9c3de619e13e ("libbpf: Use dynamically allocated buffer when receiving netlink messages")
Signed-off-by Andrii Nakryiko <[email protected]>
--- tools/lib/bpf/netlink.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/lib/bpf/netlink.c +5 -3
@@ -176,7 +176,8 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,libbpf_nla_dump_errormsg (nh); goto done;case NLMSG_DONE : -return 0 ; + ret =0 ; + goto done;default :break ; }
@@ -188,9 +189,10 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,case NL_NEXT : goto start;case NL_DONE : -return 0 ; + ret =0 ; + goto done;default : -return ret; + goto done; } } }
Signature · 1 line
2.30.2
Quoted 6 lines · Andrii Nakryiko
Ensure that
libbpf_netlink_recv()frees dynamically allocated buffer in all code paths.Cc Toke Høiland-Jørgensen <[email protected]>Fixes 9c3de619e13e ("libbpf: Use dynamically allocated buffer when receiving netlink messages")Signed-off-by Andrii Nakryiko <[email protected]>
Oops! I saw there were already 'goto done' labels in that block of code so assumed it was all fine and didn't look closer. Thank you for the fix!
-Toke
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Wed, 16 Feb 2022 23:39:58 -0800 you wrote:
Ensure that
libbpf_netlink_recv()frees dynamically allocated buffer in all code paths.Cc Toke Høiland-Jørgensen <[email protected]>Fixes 9c3de619e13e ("libbpf: Use dynamically allocated buffer when receiving netlink messages")Signed-off-by Andrii Nakryiko <[email protected]>[...]
Here is the summary with links:
- [bpf-next] libbpf: fix memleak in libbpf_netlink_recv()
https://git.kernel.org/bpf/bpf-next/c/1b8c924a0593
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html