From: Stephen Hemminger Date: Tue, 6 Nov 2018 19:30:04 +0000 (-0800) Subject: net/tap: fix file descriptor leak on error X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cc02c977189c46f0fa7de4e25f5f79c9a92cd052;p=dpdk.git net/tap: fix file descriptor leak on error If netlink socket setup fails the file descriptor was leaked. Coverity issue: 257040 Fixes: 7c25284e30c2 ("net/tap: add netlink back-end for flow API") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Keith Wiles --- diff --git a/drivers/net/tap/tap_netlink.c b/drivers/net/tap/tap_netlink.c index 6cb5100922..14bbbec754 100644 --- a/drivers/net/tap/tap_netlink.c +++ b/drivers/net/tap/tap_netlink.c @@ -51,14 +51,17 @@ tap_nl_init(uint32_t nl_groups) } if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sndbuf_size, sizeof(int))) { TAP_LOG(ERR, "Unable to set socket buffer send size"); + close(fd); return -1; } if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf_size, sizeof(int))) { TAP_LOG(ERR, "Unable to set socket buffer receive size"); + close(fd); return -1; } if (bind(fd, (struct sockaddr *)&local, sizeof(local)) < 0) { TAP_LOG(ERR, "Unable to bind to the netlink socket"); + close(fd); return -1; } return fd;