[PATCH] time: fix a missing check of rtc_read_time

From: Kangjie Lu
Date: Tue Dec 25 2018 - 23:15:31 EST


When rtc_read_time fails, we shouldn't use it read time. The fix returns
with its error code when it fails.

Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
---
kernel/time/alarmtimer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index fa5de5e8de61..19ba8a1633e0 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -293,7 +293,9 @@ 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)
+ return ret;
now = rtc_tm_to_ktime(tm);
now = ktime_add(now, min);

--
2.17.2 (Apple Git-113)