From: Mathieu Desnoyers Date: Wed, 9 Dec 2020 14:15:46 +0000 (-0500) Subject: Fix: event-notifier: Groups may not have an error counter X-Git-Tag: v2.13.0-rc1~414 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c30ad764fc2500598086902cf3bd2801b9c05c64;p=lttng-ust.git 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: Mathieu Desnoyers Change-Id: I124519d37efe8eb20296cfd74027642c8e8162a5 --- diff --git a/liblttng-ust/event-notifier-notification.c b/liblttng-ust/event-notifier-notification.c index ae997eb7..5f7d9d58 100644 --- a/liblttng-ust/event-notifier-notification.c +++ b/liblttng-ust/event-notifier-notification.c @@ -287,6 +287,10 @@ static 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( event_notifier_group->error_counter->counter,