From b0a23296344e57bd2e48e62ec2d7e0d8a38661bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sat, 12 Jan 2019 14:53:56 -0500 Subject: [PATCH] Fix: leak of filter bytecode and expression on agent event re-enable MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng-sessiond/event.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index f97148db1..b0b37bed7 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -506,7 +506,8 @@ int event_agent_enable(struct ltt_ust_session *usess, ret = LTTNG_ERR_NOMEM; goto error; } - + filter = NULL; + filter_expression = NULL; created = 1; } @@ -533,13 +534,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; } -- 2.34.1