Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 970b2564 authored by Stanley Tng's avatar Stanley Tng
Browse files

Assert if alarm callback is null

Crash the system when callback is null. This will help to identify and debug the problem. Previously, we got a CFI crash which is hard to isolate.

Test: Run with Hearing Aids but did not simulate the error condition
Bug: 119533256
Change-Id: I9bc2af7c3c405bea3a57c5feb9b213614484507f
parent 00b6cb93
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -561,11 +561,16 @@ static void alarm_ready_generic(alarm_t* alarm,
  if (alarm == NULL) {
    return;  // The alarm was probably canceled
  }

  //
  // If the alarm is not periodic, we've fully serviced it now, and can reset
  // some of its internal state. This is useful to distinguish between expired
  // alarms and active ones.
  //
  if (!alarm->callback) {
    LOG(FATAL) << __func__
               << ": timer callback is NULL! Name=" << alarm->stats.name;
  }
  alarm_callback_t callback = alarm->callback;
  void* data = alarm->data;
  uint64_t deadline_ms = alarm->deadline_ms;