aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2018-06-05 17:09:14 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-06-07 14:09:49 -0400
commitabfdff44bc38e9e2ef7929f633fb8462632299d4 (patch)
tree0ac2c1257f51bc418edf8b28b3ca2efdd48ae98c
parent1928906d126f647ff025a54df4ed88c05b2afba9 (diff)
rtc: ensure rtc_set_alarm fails when alarms are not supported
When using RTC_ALM_SET or RTC_WKALM_SET with rtc_wkalrm.enabled not set, rtc_timer_enqueue() is not called and rtc_set_alarm() may succeed but the subsequent RTC_AIE_ON ioctl will fail. RTC_ALM_READ would also fail in that case. Ensure rtc_set_alarm() fails when alarms are not supported to avoid letting programs think the alarms are working for a particular RTC when they are not. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r--drivers/rtc/interface.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 7cbdc9228dd5..6d4012dd6922 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -441,6 +441,11 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
441{ 441{
442 int err; 442 int err;
443 443
444 if (!rtc->ops)
445 return -ENODEV;
446 else if (!rtc->ops->set_alarm)
447 return -EINVAL;
448
444 err = rtc_valid_tm(&alarm->time); 449 err = rtc_valid_tm(&alarm->time);
445 if (err != 0) 450 if (err != 0)
446 return err; 451 return err;