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:21:48 +0000 (13:21 -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 bf33f5a6404014927c260a2099f3c8e7eee18593..0a9b428e0e3b2f9f564db3fa2a148a4d2fe67aa0 100644 (file)
@@ -904,6 +904,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);
@@ -929,6 +931,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 38bf2ebaaaa47ca3677b1ef35fb18cfbd8d59b6f..bd99cfa09c68a3a3fe8a641c0eaecdab9ecf272d 100644 (file)
@@ -690,6 +690,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.030253 seconds and 4 git commands to generate.