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, 21 Jan 2019 21:29:44 +0000 (16:29 -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 b7b80d366c6ed60d9027ffcfd1e3320c60cc18d0..e2c4c553f40c736917627c9091c1c02836e0f765 100644 (file)
@@ -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;
 }
 
This page took 0.027782 seconds and 4 git commands to generate.