From: Mathieu Desnoyers Date: Wed, 3 Mar 2021 15:10:16 +0000 (-0500) Subject: Fix: memory leaks on event destroy X-Git-Tag: v2.13.0-rc1~41 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=966ad25338569b3afbc1e900ec791eba54c67c9b;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/include/lttng/events.h b/include/lttng/events.h index 51892335..e6572680 100644 --- a/include/lttng/events.h +++ b/include/lttng/events.h @@ -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); diff --git a/src/lttng-events.c b/src/lttng-events.c index cb1eb5bf..3569be68 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -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); }