From: Mathieu Desnoyers Date: Wed, 3 Mar 2021 15:10:16 +0000 (-0500) Subject: Fix: memory leaks on event destroy X-Git-Tag: v2.11.9~18 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=509680fb2f8f2100bb435a4a7895e9f97242cd3f;p=lttng-modules.git Fix: memory leaks on event destroy 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 Change-Id: Ice9b1c18b47584838aea2b965494d3c8391f4c84 --- diff --git a/lttng-events.c b/lttng-events.c index bf33f5a6..0a9b428e 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -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); } diff --git a/lttng-events.h b/lttng-events.h index 38bf2eba..bd99cfa0 100644 --- a/lttng-events.h +++ b/lttng-events.h @@ -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);