From a83d68311879e618ea79a0f2a9f3e53e05855c7e Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 27 Nov 2020 14:40:08 -0500 Subject: [PATCH] Fix: event-notifier: Groups may not have an error counter 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 Signed-off-by: Mathieu Desnoyers Change-Id: I7ba68f9ae5b7b66cea538cf030bc5e1287d6eace --- src/lttng-event-notifier-notification.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lttng-event-notifier-notification.c b/src/lttng-event-notifier-notification.c index 82424e8f..f681d9b7 100644 --- a/src/lttng-event-notifier-notification.c +++ b/src/lttng-event-notifier-notification.c @@ -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( -- 2.34.1