diff options
author | Emmanuel Nicolet <emmanuel.nicolet@gmail.com> | 2019-09-27 13:04:46 +0200 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-10-03 21:55:17 +0200 |
commit | eaa6ef563d1a60fbfe6c128bf8fdb74405035b0c (patch) | |
tree | 85341021e9cd0a92945a1431d530e6f4558ce172 /drivers/rtc/interface.c | |
parent | 288d9cf1764a25eb6bb92e532a75ae90f9cb9616 (diff) | |
download | linux-eaa6ef563d1a60fbfe6c128bf8fdb74405035b0c.tar.gz linux-eaa6ef563d1a60fbfe6c128bf8fdb74405035b0c.tar.bz2 linux-eaa6ef563d1a60fbfe6c128bf8fdb74405035b0c.zip |
rtc: interface: use timeu64_t for range_max
For rtc drivers where rtc->range_max is set U64_MAX, like the PS3 rtc,
rtc_valid_range() always returns -ERANGE. This is because the local
variable range_max has type time64_t, so the test
if (time < range_min || time > range_max)
return -ERANGE;
becomes (time < range_min || time > -1), which always evaluates to true.
timeu64_t should be used, since it's the type of rtc->range_max.
Signed-off-by: Emmanuel Nicolet <emmanuel.nicolet@gmail.com>
Link: https://lore.kernel.org/r/20190927110446.GA6289@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/interface.c')
-rw-r--r-- | drivers/rtc/interface.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index c93ef33b01d3..eea700723976 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -70,7 +70,7 @@ static int rtc_valid_range(struct rtc_device *rtc, struct rtc_time *tm) time64_t time = rtc_tm_to_time64(tm); time64_t range_min = rtc->set_start_time ? rtc->start_secs : rtc->range_min; - time64_t range_max = rtc->set_start_time ? + timeu64_t range_max = rtc->set_start_time ? (rtc->start_secs + rtc->range_max - rtc->range_min) : rtc->range_max; |