From 507c41ee0aad3952c08ab9965467f7c05d03195a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 14 Jul 2014 14:06:03 -0700 Subject: [PATCH] netlink-socket: Fix handling socket allocation failure in nl_dump_start(). If nl_pool_alloc() failed, then 'dump' was not initialized at all and further use of the dump would access uninitialized data, probably causing a crash. Found by inspection. Signed-off-by: Ben Pfaff Acked-by: Joe Stringer --- lib/netlink-socket.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index a769de8f8..670d0a9b0 100644 --- a/lib/netlink-socket.c +++ b/lib/netlink-socket.c @@ -702,15 +702,14 @@ nl_sock_drain(struct nl_sock *sock) void nl_dump_start(struct nl_dump *dump, int protocol, const struct ofpbuf *request) { - int status = nl_pool_alloc(protocol, &dump->sock); - - if (status) { - return; - } + int status; nl_msg_nlmsghdr(request)->nlmsg_flags |= NLM_F_DUMP | NLM_F_ACK; - status = nl_sock_send__(dump->sock, request, - nl_sock_allocate_seq(dump->sock, 1), true); + status = nl_pool_alloc(protocol, &dump->sock); + if (!status) { + status = nl_sock_send__(dump->sock, request, + nl_sock_allocate_seq(dump->sock, 1), true); + } atomic_init(&dump->status, status << 1); dump->nl_seq = nl_msg_nlmsghdr(request)->nlmsg_seq; dump->status_seq = seq_create(); -- 2.20.1