[PATCH] drivers/rtc/interface.c: check the error after __rtc_read_time()
From: Hyogi Gim
Date: Tue Dec 16 2014 - 22:17:09 EST
Add the verification code for returned __rtc_read_time() error in
rtc_update_irq_enable() and rtc_timer_do_work().
Signed-off-by: Hyogi Gim <hyogi.gim@xxxxxxx>
---
drivers/rtc/interface.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 45bfc28ee..fa1f119 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -489,7 +489,10 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
struct rtc_time tm;
ktime_t now, onesec;
- __rtc_read_time(rtc, &tm);
+ err = __rtc_read_time(rtc, &tm);
+ if (err < 0)
+ goto out;
+
onesec = ktime_set(1, 0);
now = rtc_tm_to_ktime(tm);
rtc->uie_rtctimer.node.expires = ktime_add(now, onesec);
@@ -867,13 +870,17 @@ void rtc_timer_do_work(struct work_struct *work)
struct timerqueue_node *next;
ktime_t now;
struct rtc_time tm;
+ int err = 0;
struct rtc_device *rtc =
container_of(work, struct rtc_device, irqwork);
mutex_lock(&rtc->ops_lock);
again:
- __rtc_read_time(rtc, &tm);
+ err = __rtc_read_time(rtc, &tm);
+ if (err < 0)
+ goto out;
+
now = rtc_tm_to_ktime(tm);
while ((next = timerqueue_getnext(&rtc->timerqueue))) {
if (next->expires.tv64 > now.tv64)
@@ -898,7 +905,6 @@ again:
/* Set next alarm */
if (next) {
struct rtc_wkalrm alarm;
- int err;
int retry = 3;
alarm.time = rtc_ktime_to_tm(next->expires);
@@ -920,6 +926,7 @@ reprogram:
} else
rtc_alarm_disable(rtc);
+out:
pm_relax(rtc->dev.parent);
mutex_unlock(&rtc->ops_lock);
}
--
1.8.3.2
--
Hyogi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/