From d9c6b5f258e9b72fb1da7492f4001dd0976e9886 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 25 Sep 2019 18:04:14 -0400 Subject: [PATCH] Fix: sessiond: leak of application socket on chmod failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng-sessiond/register.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/register.c b/src/bin/lttng-sessiond/register.c index e809834fa..ecb0dfef0 100644 --- a/src/bin/lttng-sessiond/register.c +++ b/src/bin/lttng-sessiond/register.c @@ -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; } /* -- 2.34.1