From b36a0044e097a82d6c7e61b384a7d80a9b8192d7 Mon Sep 17 00:00:00 2001 From: Jim Wylder Date: Mon, 14 Jul 2014 12:51:58 -0500 Subject: IKXCLOCK-2803 alarmtimer: check rtc_read_time return value If we are not able to read the current time, there is no value in attempting to schedule an alarm based on that time. In some cases, the stack value for time can look close enough to a future time to make it through validity checking, but not be a valid timer event. Change-Id: I2f29087deefb12222043d80f506cb41d89e7f9e1 Signed-off-by: Jim Wylder --- kernel/time/alarmtimer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'kernel') diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 3e5cba27447..07f7c6f9330 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -260,12 +260,15 @@ static int alarmtimer_suspend(struct device *dev) /* Setup an rtc timer to fire that far in the future */ rtc_timer_cancel(rtc, &rtctimer); - rtc_read_time(rtc, &tm); + ret = rtc_read_time(rtc, &tm); + if (ret < 0) + goto out; now = rtc_tm_to_ktime(tm); now = ktime_add(now, min); /* Set alarm, if in the past reject suspend briefly to handle */ ret = rtc_timer_start(rtc, &rtctimer, now, ktime_set(0, 0)); +out: if (ret < 0) __pm_wakeup_event(ws, MSEC_PER_SEC); return ret; -- cgit v1.2.3-70-g09d2