Fix: sessiond: leak of trigger on registration error
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 9 Feb 2021 22:08:45 +0000 (17:08 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 9 Feb 2021 23:39:30 +0000 (18:39 -0500)
The caller of cmd_register_trigger assumes that no triggers are returned
on error. This causes a leak of the reference to the returned trigger.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7377f9d4227c85feadba1778cf3c910ac677adac

src/bin/lttng-sessiond/cmd.c

index 505645bf1ce1cb69c864fadb322a3d366e493944..8d36e7192c8deb32a46ca471c5d58dafd5e19d63 100644 (file)
@@ -4459,10 +4459,12 @@ enum lttng_error_code cmd_register_trigger(const struct lttng_credentials *cmd_c
         * reference to the trigger so the caller doesn't have to care if those
         * are distinct instances or not.
         */
-       lttng_trigger_get(trigger);
-       *return_trigger = trigger;
-       /* Ownership of trigger was transferred to caller. */
-       trigger = NULL;
+       if (ret_code == LTTNG_OK) {
+               lttng_trigger_get(trigger);
+               *return_trigger = trigger;
+               /* Ownership of trigger was transferred to caller. */
+               trigger = NULL;
+       }
 end:
        return ret_code;
 end_unlock_session_list:
This page took 0.027901 seconds and 4 git commands to generate.