From c7bb28d33fb7cdc8dd5484739a94beb3cb1f869a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 19 Feb 2019 16:25:17 -0500 Subject: [PATCH] Fix relayd: session leaked on communication error during creation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit A relay_session object can be leaked if the relay daemon fails to reply to the RELAYD_CREATE_SESSION command. Since the relay daemon's peer can't know the session's id, the session will never be referenced in the future. Moreover, the session will never be tied to the connection(s) in order to bound its lifetime. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index de14cdb43..e81bdeffc 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -1099,7 +1099,7 @@ static int relay_create_session(const struct lttcomm_relayd_hdr *recv_hdr, { int ret = 0; ssize_t send_ret; - struct relay_session *session; + struct relay_session *session = NULL; struct lttcomm_relayd_status_session reply; char session_name[LTTNG_NAME_MAX]; char hostname[LTTNG_HOST_NAME_MAX]; @@ -1153,7 +1153,9 @@ send_reply: send_ret); ret = -1; } - + if (ret < 0 && session) { + session_put(session); + } return ret; } -- 2.34.1