From: Jérémie Galarneau Date: Wed, 25 Sep 2019 22:04:14 +0000 (-0400) Subject: Fix: sessiond: leak of application socket on chmod failure X-Git-Tag: v2.12.0-rc1~351 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d9c6b5f258e9b72fb1da7492f4001dd0976e9886;p=lttng-tools.git Fix: sessiond: leak of application socket on chmod failure 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 --- 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; } /*