Skip to content

Commit

Permalink
libbpf: Fix memleak in libbpf_netlink_recv()
Browse files Browse the repository at this point in the history
[ Upstream commit 1b8c924 ]

Ensure that libbpf_netlink_recv() frees dynamically allocated buffer in
all code paths.

Fixes: 9c3de61 ("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>
  • Loading branch information
anakryiko authored and gregkh committed Apr 8, 2022
1 parent 0da0a33 commit c3d6656
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/lib/bpf/netlink.c
Expand Up @@ -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;
}
Expand All @@ -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;
}
}
}
Expand Down

0 comments on commit c3d6656

Please sign in to comment.