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>
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);
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;
}
/*