[lttng-tools] Fix: Close socket handle on error
diff mbox series

Message ID 20190920153421.67837-1-jonathan.rajotte-julien@efficios.com
State Accepted, archived
Headers show
Series
  • [lttng-tools] Fix: Close socket handle on error
Related show

Commit Message

Jonathan Rajotte Sept. 20, 2019, 3:34 p.m. UTC
Fixes coverity #1399739

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
---
 src/bin/lttng-sessiond/client.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jérémie Galarneau Sept. 20, 2019, 9:23 p.m. UTC | #1
Merged in master and stable-2.11. Thanks!

J?r?mie

On Fri, Sep 20, 2019 at 11:34:21AM -0400, Jonathan Rajotte wrote:
> Fixes coverity #1399739
> 
> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
>  src/bin/lttng-sessiond/client.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c
> index 956dab8c8..870277534 100644
> --- a/src/bin/lttng-sessiond/client.c
> +++ b/src/bin/lttng-sessiond/client.c
> @@ -1985,8 +1985,11 @@ static int create_client_sock(void)
>  	/* File permission MUST be 660 */
>  	ret = chmod(config.client_unix_sock_path.value, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
>  	if (ret < 0) {
> -		ERR("Set file permissions failed: %s", config.client_unix_sock_path.value);
> +		ERR("Set file permissions failed: %s",
> +				config.client_unix_sock_path.value);
>  		PERROR("chmod");
> +		(void) lttcomm_close_unix_sock(client_sock);
> +		ret = -1;
>  		goto end;
>  	}
>  	DBG("Created client socket (fd = %i)", client_sock);
> -- 
> 2.17.1
>

Patch
diff mbox series

diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c
index 956dab8c8..870277534 100644
--- a/src/bin/lttng-sessiond/client.c
+++ b/src/bin/lttng-sessiond/client.c
@@ -1985,8 +1985,11 @@  static int create_client_sock(void)
 	/* File permission MUST be 660 */
 	ret = chmod(config.client_unix_sock_path.value, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
 	if (ret < 0) {
-		ERR("Set file permissions failed: %s", config.client_unix_sock_path.value);
+		ERR("Set file permissions failed: %s",
+				config.client_unix_sock_path.value);
 		PERROR("chmod");
+		(void) lttcomm_close_unix_sock(client_sock);
+		ret = -1;
 		goto end;
 	}
 	DBG("Created client socket (fd = %i)", client_sock);