Skip to content

Commit 1b8c924

Browse files
anakryikoborkmann
authored andcommitted
libbpf: Fix memleak in libbpf_netlink_recv()
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 <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Toke Høiland-Jørgensen <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 9b6eb04 commit 1b8c924

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/lib/bpf/netlink.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,
176176
libbpf_nla_dump_errormsg(nh);
177177
goto done;
178178
case NLMSG_DONE:
179-
return 0;
179+
ret = 0;
180+
goto done;
180181
default:
181182
break;
182183
}
@@ -188,9 +189,10 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,
188189
case NL_NEXT:
189190
goto start;
190191
case NL_DONE:
191-
return 0;
192+
ret = 0;
193+
goto done;
192194
default:
193-
return ret;
195+
goto done;
194196
}
195197
}
196198
}

0 commit comments

Comments
 (0)