[dpdk-dev] [PATCH 3/4] net/tap: fix file descriptor leak on error

Wiles, Keith keith.wiles at intel.com
Wed Nov 7 11:02:50 CET 2018



> On Nov 6, 2018, at 7:30 PM, Stephen Hemminger <stephen at networkplumber.org> wrote:
> 
> If netlink socket setup fails the file descriptor was leaked.

Acked-by: Keith Wiles <keith.wiles at intel.com>
> 
> Coverity issue: 257040
> Fixes: 7c25284e30c2 ("net/tap: add netlink back-end for flow API")
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
> drivers/net/tap/tap_netlink.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/tap/tap_netlink.c b/drivers/net/tap/tap_netlink.c
> index 6cb510092218..14bbbec754f6 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;
> -- 
> 2.17.1
> 

Regards,
Keith



More information about the dev mailing list