Fix: fd leak in inet accept call
authorDavid Goulet <dgoulet@efficios.com>
Tue, 30 Sep 2014 15:59:49 +0000 (11:59 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 30 Sep 2014 15:59:49 +0000 (11:59 -0400)
Fixes Coverity issue #1241799.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/sessiond-comm/inet.c

index cf06ecb858d2079455c7a009f888435b6532d6c4..32a16a690342976a68c4d84f6e5c94abd7ad6d14 100644 (file)
@@ -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;
This page took 0.025506 seconds and 4 git commands to generate.