From: Jérémie Galarneau Date: Tue, 9 Feb 2021 22:08:45 +0000 (-0500) Subject: Fix: sessiond: leak of trigger on registration error X-Git-Tag: v2.13.0-rc1~343 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=39b95a70bbb440eb42a548df21742f6ddebe0e2d;p=lttng-tools.git Fix: sessiond: leak of trigger on registration error 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 Change-Id: I7377f9d4227c85feadba1778cf3c910ac677adac --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 505645bf1..8d36e7192 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -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: