diff options
author | Andrii Nakryiko | 2022-02-16 23:39:58 -0800 |
---|---|---|
committer | Daniel Borkmann | 2022-02-17 16:09:07 +0100 |
commit | 1b8c924a05934d2e758ec7da7bd217ef8ebd80ce (patch) | |
tree | 923f14c801fdd8f454ef2d8e23954146d65ac78b /tools/lib | |
parent | 9b6eb0478dfad3b0e7af6c73523d96826210f4fe (diff) |
libbpf: Fix memleak in libbpf_netlink_recv()
Ensure that libbpf_netlink_recv() frees dynamically allocated buffer in
all code paths.
Fixes: 9c3de619e13e ("libbpf: Use dynamically allocated buffer when receiving netlink messages")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20220217073958.276959-1-andrii@kernel.org
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/bpf/netlink.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c index a598061f6fea..cbc8967d5402 100644 --- a/tools/lib/bpf/netlink.c +++ b/tools/lib/bpf/netlink.c @@ -176,7 +176,8 @@ start: libbpf_nla_dump_errormsg(nh); goto done; case NLMSG_DONE: - return 0; + ret = 0; + goto done; default: break; } @@ -188,9 +189,10 @@ start: case NL_NEXT: goto start; case NL_DONE: - return 0; + ret = 0; + goto done; default: - return ret; + goto done; } } } |