Fix: sessiond: leak of application socket on chmod failure
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 25 Sep 2019 22:04:14 +0000 (18:04 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 25 Sep 2019 22:04:14 +0000 (18:04 -0400)
The apps_sock fd is leaked whenever the chmod of the application
socket fails. Add a clean-up error path.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/register.c

index e809834faa4632b961d19053145b39b23c0f9e9a..ecb0dfef07457e1ca68aa76d749ed9981cbf4c10 100644 (file)
@@ -72,7 +72,7 @@ static int create_application_socket(void)
        if (ret < 0) {
                PERROR("Set file permissions failed on %s",
                                config.apps_unix_sock_path.value);
-               goto end;
+               goto error_close_socket;
        }
 
        DBG3("Session daemon application socket created (fd = %d) ", apps_sock);
@@ -80,6 +80,13 @@ static int create_application_socket(void)
 end:
        umask(old_umask);
        return ret;
+error_close_socket:
+       if (close(apps_sock)) {
+               PERROR("Failed to close application socket in error path");
+       }
+       apps_sock = -1;
+       ret = -1;
+       goto end;
 }
 
 /*
This page took 0.02665 seconds and 5 git commands to generate.