]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
rtc: ensure rtc_set_alarm fails when alarms are not supported
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Tue, 5 Jun 2018 21:09:14 +0000 (23:09 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 1 Mar 2019 13:20:30 +0000 (14:20 +0100)
BugLink: http://bugs.launchpad.net/bugs/1815234
[ Upstream commit abfdff44bc38e9e2ef7929f633fb8462632299d4 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/rtc/interface.c

index 672b192f8153aa00665daaefc541ebaf601cfe74..6623185dfa4e3e70514c6799890a662d4303c943 100644 (file)
@@ -359,6 +359,11 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
 {
        int err;
 
+       if (!rtc->ops)
+               return -ENODEV;
+       else if (!rtc->ops->set_alarm)
+               return -EINVAL;
+
        err = rtc_valid_tm(&alarm->time);
        if (err != 0)
                return err;