Fix relayd: session leaked on communication error during creation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 19 Feb 2019 21:25:17 +0000 (16:25 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Mar 2019 16:29:19 +0000 (12:29 -0400)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/main.c

index de14cdb432d977c6fb1fa2cf982e435a5c0063d5..e81bdeffc82b97790ddf99bf6bb473636b0f4064 100644 (file)
@@ -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;
 }
 
This page took 0.02807 seconds and 4 git commands to generate.