From: Mathieu Desnoyers Date: Thu, 4 Nov 2021 21:05:10 +0000 (-0400) Subject: Fix: clear error counter before adding to lists X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c4e310594ea3bd6d5110bcda972c0920e95a6eaf;p=lttng-modules.git Fix: clear error counter before adding to lists Adding to lists should be the last thing in the create function, otherwise errors on error counter clear may lead to use-after-free due to presence of freed objects in linked lists. Signed-off-by: Mathieu Desnoyers Change-Id: Ia6fb83cd053c2122939add6c330834199514b0e5 --- diff --git a/src/lttng-events.c b/src/lttng-events.c index 828cb184..981ee30c 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -1466,12 +1466,13 @@ struct lttng_kernel_event_notifier *_lttng_kernel_event_notifier_create(struct l goto register_error; } - list_add(&event->priv->node, event_list_head); - hlist_add_head(&event->priv->hlist_node, head); - ret = lttng_kernel_event_notifier_clear_error_counter(event); if (ret) goto register_error; + + list_add(&event->priv->node, event_list_head); + hlist_add_head(&event->priv->hlist_node, head); + return event_notifier; register_error: