From: David Goulet Date: Tue, 30 Sep 2014 15:59:49 +0000 (-0400) Subject: Fix: fd leak in inet accept call X-Git-Tag: v2.6.0-rc1~28 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=475cd9fa36ab2ad108f94bb8292bdcdbbbc6e38f;p=lttng-tools.git Fix: fd leak in inet accept call Fixes Coverity issue #1241799. Signed-off-by: David Goulet --- diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index cf06ecb85..32a16a690 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -305,11 +305,11 @@ struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) ret = lttcomm_setsockopt_rcv_timeout(new_fd, timeout); if (ret) { - goto error; + goto error_close; } ret = lttcomm_setsockopt_snd_timeout(new_fd, timeout); if (ret) { - goto error; + goto error_close; } } @@ -319,6 +319,11 @@ struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock) end: return new_sock; +error_close: + if (close(new_fd) < 0) { + PERROR("accept inet close fd"); + } + error: free(new_sock); return NULL;