diff options
Diffstat (limited to 'drivers/rtc/interface.c')
-rw-r--r-- | drivers/rtc/interface.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 7e253be19ba7..c068daebeec2 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -70,6 +70,13 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm) if (err != 0) return err; + if (rtc->range_min != rtc->range_max) { + time64_t time = rtc_tm_to_time64(tm); + + if (time < rtc->range_min || time > rtc->range_max) + return -ERANGE; + } + err = mutex_lock_interruptible(&rtc->ops_lock); if (err) return err; @@ -374,6 +381,13 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) if (err != 0) return err; + if (rtc->range_min != rtc->range_max) { + time64_t time = rtc_tm_to_time64(&alarm->time); + + if (time < rtc->range_min || time > rtc->range_max) + return -ERANGE; + } + err = mutex_lock_interruptible(&rtc->ops_lock); if (err) return err; |