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:15:46 +0000 (13:15 -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

include/lttng/events.h
src/lttng-events.c

index 51892335010afea17f1056a7a4a010a19e75f672..e6572680e6c6af76c28a55ae9b4df0cf6800be51 100644 (file)
@@ -986,6 +986,7 @@ void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
                struct lttng_ctx *ctx,
                struct list_head *instance_bytecode_runtime_head,
                struct list_head *enabler_bytecode_runtime_head);
+void lttng_free_event_filter_runtime(struct lttng_event *event);
 
 int lttng_probes_init(void);
 
index cb1eb5bf030ea233c15309e3c8baa21a04402c43..3569be68d1151077182b60b996905538b9f10cea 100644 (file)
@@ -1485,6 +1485,8 @@ int _lttng_event_notifier_unregister(
 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_desc_put(event->desc);
@@ -1510,6 +1512,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);
 }
 
This page took 0.028138 seconds and 4 git commands to generate.