From: Jérémie Galarneau Date: Sat, 12 Jan 2019 19:53:56 +0000 (-0500) Subject: Fix: leak of filter bytecode and expression on agent event re-enable X-Git-Tag: v2.10.6~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5e28af3877ffdb24d0462d9a4ba77f2128cf9cc7;p=lttng-tools.git Fix: leak of filter bytecode and expression on agent event re-enable The agent subsystem does not properly assume the clean-up of an event's filter bytecode and expression when a previously disabled event is re-enabled. This change ensures that the ownership of both the filter bytecode and expression is assumed by the agent subsystem and discarded when a matching event is found. Steps to reproduce the leak: $ lttng create $ lttng enable-event --python allo --filter 'a[42] == 241' $ lttng disable-event --python allo $ lttng enable-event --python allo --filter 'a[42] == 241' Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index b7b80d366..e2c4c553f 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -512,12 +512,14 @@ int event_agent_enable(struct ltt_ust_session *usess, ret = LTTNG_ERR_NOMEM; goto error; } - + filter = NULL; + filter_expression = NULL; created = 1; } /* Already enabled? */ if (aevent->enabled) { + ret = LTTNG_OK; goto end; } @@ -538,13 +540,16 @@ int event_agent_enable(struct ltt_ust_session *usess, agent_add_event(aevent, agt); } -end: - return LTTNG_OK; + ret = LTTNG_OK; + goto end; error: if (created) { agent_destroy_event(aevent); } +end: + free(filter); + free(filter_expression); return ret; }