From: Jérémie Galarneau Date: Tue, 18 Feb 2020 00:40:47 +0000 (-0500) Subject: Fix: relayd: live: unchecked return value when opening relay socket X-Git-Tag: v2.13.0-rc1~762 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d546eeec57f3d23255e55d6d7384ab825bae8218;p=lttng-tools.git Fix: relayd: live: unchecked return value when opening relay socket fd_tracker_open_unsuspendable_fd may fail because the underlying socket() call fails or there may be too many open file descriptors at the time of the call. In both cases, these errors must be logged and handled. Signed-off-by: Jérémie Galarneau Change-Id: I3205896a5e8c83ceba02005a2b73f9466d26427c --- diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index f28b9c66f..3ddafe2a1 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -561,7 +561,11 @@ struct lttcomm_sock *init_socket(struct lttng_uri *uri, const char *name) ret = fd_tracker_open_unsuspendable_fd(the_fd_tracker, &sock_fd, (const char **) (formated_name ? &formated_name : NULL), 1, create_sock, sock); - free(formated_name); + if (ret) { + PERROR("Failed to create \"%s\" socket", + formated_name ?: "Unknown"); + goto error; + } DBG("Listening on %s socket %d", name, sock->fd); ret = sock->ops->bind(sock); @@ -576,12 +580,14 @@ struct lttcomm_sock *init_socket(struct lttng_uri *uri, const char *name) } + free(formated_name); return sock; error: if (sock) { lttcomm_destroy_sock(sock); } + free(formated_name); return NULL; }