Fix: memory leaks on event destroy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Mar 2021 15:10:16 +0000 (10:10 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Mar 2021 18:17:56 +0000 (13:17 -0500)
Both filter runtime and event enabler ref objects are owned by the
event, but are not freed upon destruction of the event object, thus
leaking memory.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ice9b1c18b47584838aea2b965494d3c8391f4c84

lttng-events.c
lttng-events.h

index f3398adc6f11d6db7bc3ce8844fb2a3c3dcbc10f..984bd341a162d4d76cf8f2a61ab6c9ae5445353c 100644 (file)
@@ -919,6 +919,8 @@ int _lttng_event_unregister(struct lttng_event *event)
 static
 void _lttng_event_destroy(struct lttng_event *event)
 {
+       struct lttng_enabler_ref *enabler_ref, *tmp_enabler_ref;
+
        switch (event->instrumentation) {
        case LTTNG_KERNEL_TRACEPOINT:
                lttng_event_put(event->desc);
@@ -944,6 +946,11 @@ void _lttng_event_destroy(struct lttng_event *event)
        }
        list_del(&event->list);
        lttng_destroy_context(event->ctx);
+       lttng_free_event_filter_runtime(event);
+       /* Free event enabler refs */
+       list_for_each_entry_safe(enabler_ref, tmp_enabler_ref,
+                                &event->enablers_ref_head, node)
+               kfree(enabler_ref);
        kmem_cache_free(event_cache, event);
 }
 
index 1b9ab167588ff651d9677d3659e2b920eeca7af4..13b6abf5cf0d4e7c1fc64c0fa4c3d364f50344e4 100644 (file)
@@ -716,6 +716,7 @@ int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
                struct lttng_kernel_filter_bytecode __user *bytecode);
 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
                struct lttng_enabler *enabler);
+void lttng_free_event_filter_runtime(struct lttng_event *event);
 
 int lttng_probes_init(void);
 
This page took 0.027567 seconds and 4 git commands to generate.