Fix: clear error counter before adding to lists
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Nov 2021 21:05:10 +0000 (17:05 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Nov 2021 21:05:10 +0000 (17:05 -0400)
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 <mathieu.desnoyers@efficios.com>
Change-Id: Ia6fb83cd053c2122939add6c330834199514b0e5

src/lttng-events.c

index 828cb18460477a2f13f5fc724abe2669c3ed96ba..981ee30c326cb65be35ff7b6d107d600e09633a4 100644 (file)
@@ -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:
This page took 0.027064 seconds and 4 git commands to generate.