2014-07-04 01:23:16

by Hyogi Gim

[permalink] [raw]
Subject: [PATCH] drivers/rtc/interface.c: check the error after __rtc_read_time()

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 <[email protected]>
---
drivers/rtc/interface.c | 2 ++
1 file changed, 2 insertions(+)

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;
--
1.8.3.2


2014-07-04 10:10:05

by Alessandro Zummo

[permalink] [raw]
Subject: Re: [rtc-linux] [PATCH] drivers/rtc/interface.c: check the error after __rtc_read_time()

On Fri, 4 Jul 2014 10:22:26 +0900
Hyogi Gim <[email protected]> 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 <[email protected]>

Acked-by: Alessandro Zummo <[email protected]>

--

Best regards,

Alessandro Zummo,
Tower Technologies - Torino, Italy

http://www.towertech.it

2014-07-30 17:44:48

by John Stultz

[permalink] [raw]
Subject: Re: [PATCH] drivers/rtc/interface.c: check the error after __rtc_read_time()

On Thu, Jul 3, 2014 at 6:22 PM, Hyogi Gim <[email protected]> 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 <[email protected]>

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