From: Francis Deslauriers Date: Fri, 27 Nov 2020 19:40:08 +0000 (-0500) Subject: Fix: event-notifier: Groups may not have an error counter X-Git-Tag: v2.13.0-rc1~76 X-Git-Url: http://git.lttng.org/?p=lttng-modules.git;a=commitdiff_plain;h=a83d68311879e618ea79a0f2a9f3e53e05855c7e 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 --- 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(