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) | |||
70 | if (err != 0) | 70 | if (err != 0) |
71 | return err; | 71 | return err; |
72 | 72 | ||
73 | if (rtc->range_min != rtc->range_max) { | ||
74 | time64_t time = rtc_tm_to_time64(tm); | ||
75 | |||
76 | if (time < rtc->range_min || time > rtc->range_max) | ||
77 | return -ERANGE; | ||
78 | } | ||
79 | |||
73 | err = mutex_lock_interruptible(&rtc->ops_lock); | 80 | err = mutex_lock_interruptible(&rtc->ops_lock); |
74 | if (err) | 81 | if (err) |
75 | return err; | 82 | return err; |
@@ -374,6 +381,13 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
374 | if (err != 0) | 381 | if (err != 0) |
375 | return err; | 382 | return err; |
376 | 383 | ||
384 | if (rtc->range_min != rtc->range_max) { | ||
385 | time64_t time = rtc_tm_to_time64(&alarm->time); | ||
386 | |||
387 | if (time < rtc->range_min || time > rtc->range_max) | ||
388 | return -ERANGE; | ||
389 | } | ||
390 | |||
377 | err = mutex_lock_interruptible(&rtc->ops_lock); | 391 | err = mutex_lock_interruptible(&rtc->ops_lock); |
378 | if (err) | 392 | if (err) |
379 | return err; | 393 | return err; |