kernel: time: Fix the alarm_bases array accessing issue
Array 'alarm_bases' of size 2 may use index value(s) 0..2,
so check the alarm type before initializing.
CRs-fixed: 2206448
Change-Id: I4691b5a8a92c8a98dc78c8938a0dc9c0852c4e2e
Signed-off-by: Vamshi Krishna B V <vbv@codeaurora.org>
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index b2df539..78c0e04 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -348,6 +348,10 @@
alarm->timer.function = alarmtimer_fired;
alarm->function = function;
alarm->type = type;
+ if (type >= ALARM_NUMTYPE) {
+ /* use ALARM_BOOTTIME as the default */
+ alarm->type = ALARM_BOOTTIME;
+ }
alarm->state = ALARMTIMER_STATE_INACTIVE;
}
EXPORT_SYMBOL_GPL(alarm_init);