drivers/rtc/interface.c: check the error after __rtc_read_time()
authorHyogi Gim <hyogi.gim@lge.com>
Fri, 8 Aug 2014 21:20:11 +0000 (14:20 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Aug 2014 22:57:19 +0000 (15:57 -0700)
In __rtc_set_alarm(), the error after __rtc_read_time() is not checked.
If rtc device fail to read time, we cannot guarantee the following
process.

Add the verification code for returned __rtc_read_time() error.

Signed-off-by: Hyogi Gim <hyogi.gim@lge.com>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/interface.c

index 5813fa52c3d43328c80bdb799d38d0b1c68d129d..5b2717f5dafa73e808f9bbf29387e223109588b2 100644 (file)
@@ -348,6 +348,8 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
 
        /* Make sure we're not setting alarms in the past */
        err = __rtc_read_time(rtc, &tm);
+       if (err)
+               return err;
        rtc_tm_to_time(&tm, &now);
        if (scheduled <= now)
                return -ETIME;