From: Jérémie Galarneau Date: Tue, 18 Feb 2020 00:32:54 +0000 (-0500) Subject: Fix: relayd: unchecked return value when opening relay socket X-Git-Tag: v2.12.0-rc2~54 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=959de99b2bb3c474b1bd624f1dd3c5376d440662;p=lttng-tools.git Fix: relayd: 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: I8b8c4fcc9de08746a91778b58c74b2118e98667b --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index cbd9e9cc7..7f7c0369a 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -1022,7 +1022,11 @@ static struct lttcomm_sock *relay_socket_create(struct lttng_uri *uri, 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 open \"%s\" relay socket", + formated_name ?: "Unknown"); + goto error; + } DBG("Listening on %s socket %d", name, sock->fd); ret = sock->ops->bind(sock); @@ -1037,12 +1041,14 @@ static struct lttcomm_sock *relay_socket_create(struct lttng_uri *uri, } + free(formated_name); return sock; error: if (sock) { lttcomm_destroy_sock(sock); } + free(formated_name); return NULL; }