Fix: event-notifier: Groups may not have an error counter
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 27 Nov 2020 19:40:08 +0000 (14:40 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 27 Nov 2020 20:44:53 +0000 (15:44 -0500)
Issue
=====
If no error counter is attached to an event notifier group, calling
the `record_error()` function leads to a NULL pointer dereference.

Solution
========
Check if the error_counter field is allocated before dereferencing it.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7ba68f9ae5b7b66cea538cf030bc5e1287d6eace

src/lttng-event-notifier-notification.c

index 82424e8f0e91ea63849d00e8d538921de4d210a7..f681d9b79d24486ca03fa911967f6cc5fe7e3200 100644 (file)
@@ -355,6 +355,10 @@ void record_error(struct lttng_event_notifier *event_notifier)
        size_t dimension_index[1];
        int ret;
 
+       /* This group may not have an error counter attached to it. */
+       if (!event_notifier_group->error_counter)
+               return;
+
        dimension_index[0] = event_notifier->error_counter_index;
 
        ret = event_notifier_group->error_counter->ops->counter_add(
This page took 0.025813 seconds and 4 git commands to generate.