diff mbox

drivers/rtc/interface.c: check the error after __rtc_read_time()

Message ID 1404436946-28354-1-git-send-email-hyogi.gim@lge.com
State Accepted
Headers show

Commit Message

Hyogi Gim July 4, 2014, 1:22 a.m. UTC
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>
---
 drivers/rtc/interface.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alessandro Zummo July 4, 2014, 10:10 a.m. UTC | #1
On Fri,  4 Jul 2014 10:22:26 +0900
Hyogi Gim <hyogi.gim@lge.com> wrote:

> 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>
John Stultz July 30, 2014, 5:44 p.m. UTC | #2
On Thu, Jul 3, 2014 at 6:22 PM, Hyogi Gim <hyogi.gim@lge.com> wrote:
> 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>

Thanks for sending this in. Sorry I didn't get to it earlier. I've got
it queued for testing and hopefully will make it for 3.17 (but I may
be cutting it close).

thanks
-john
diff mbox

Patch

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 5813fa5..5b2717f 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -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;