libbpf: Fix memleak in libbpf_netlink_recv()
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 17 Feb 2022 07:39:58 +0000 (23:39 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:31 +0000 (14:23 +0200)
commitd85baefc858f443b2239aa15165eb47440b6c8f0
treefd44ebc929ef2caf2a10e38d90396d8abdc0f7a7
parent0f47edc22c2b7e4c1903d74c3992f09db9453d11
libbpf: Fix memleak in libbpf_netlink_recv()

[ Upstream commit 1b8c924a05934d2e758ec7da7bd217ef8ebd80ce ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/netlink.c