Fix: leak of filter bytecode and expression on agent event re-enable
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 12 Jan 2019 19:53:56 +0000 (14:53 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 14 Jan 2019 22:56:28 +0000 (17:56 -0500)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/event.c

index f97148db113c2bf1c8f3cc32dd9b6dd38170f599..b0b37bed777a4eb5b537b0739c14115b5e3020a2 100644 (file)
@@ -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;
 }
 
This page took 0.030393 seconds and 5 git commands to generate.