From: Jérémie Galarneau Date: Tue, 19 Feb 2019 21:25:17 +0000 (-0500) Subject: Fix relayd: session leaked on communication error during creation X-Git-Tag: v2.12.0-rc1~651 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4c6885d2d540ce66b9050e9f90c49575fb76dde0;p=lttng-tools.git Fix relayd: session leaked on communication error during creation 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 --- 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; }