Commit 1b8c924a authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Daniel Borkmann
Browse files

libbpf: Fix memleak in libbpf_netlink_recv()



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

Fixes: 9c3de619 ("libbpf: Use dynamically allocated buffer when receiving netlink messages")
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20220217073958.276959-1-andrii@kernel.org
parent 9b6eb047
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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;
				}
			}
		}