From: David Goulet Date: Wed, 12 Mar 2014 18:47:39 +0000 (-0400) Subject: Fix: check relayd fd leak in lttng cmdline X-Git-Tag: v2.4.1~12 X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;h=c0d86f35d5a6fab53b849d1147de84b99e6116a9;p=lttng-tools.git Fix: check relayd fd leak in lttng cmdline Fixes coverity issue 1188185. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng/utils.c b/src/bin/lttng/utils.c index b40465b38..257dfc89a 100644 --- a/src/bin/lttng/utils.c +++ b/src/bin/lttng/utils.c @@ -341,7 +341,8 @@ int check_relayd(void) fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { perror("socket check relayd"); - goto error; + ret = -1; + goto error_socket; } sin.sin_family = AF_INET; @@ -349,6 +350,7 @@ int check_relayd(void) ret = inet_pton(sin.sin_family, "127.0.0.1", &sin.sin_addr); if (ret < 1) { perror("inet_pton check relayd"); + ret = -1; goto error; } @@ -365,8 +367,10 @@ int check_relayd(void) ret = 1; } - return ret; - error: - return -1; + if (close(fd) < 0) { + perror("close relayd fd"); + } +error_socket: + return ret; }