mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 12:52:29 -04:00
rtc: rzn1: Fix alarm range check truncation on 32-bit systems
alarm and farest were declared as unsigned long, but rtc_tm_to_time64() returns time64_t (s64). On 32-bit systems where unsigned long is 32 bits, the assignment silently truncates the upper 32 bits of the timestamp. Fix by declaring alarm and farest as time64_t and replacing time_after() with a direct signed comparison, which is correct for time64_t values that will never realistically overflow. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-6-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
committed by
Alexandre Belloni
parent
457b5dbce3
commit
c3e735e9f6
@@ -268,7 +268,7 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
{
|
||||
struct rzn1_rtc *rtc = dev_get_drvdata(dev);
|
||||
struct rtc_time *tm = &alrm->time, tm_now;
|
||||
unsigned long alarm, farest;
|
||||
time64_t alarm, farest;
|
||||
int ret;
|
||||
|
||||
ret = rzn1_rtc_read_time(dev, &tm_now);
|
||||
@@ -278,7 +278,7 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
|
||||
/* We cannot set alarms more than one week ahead */
|
||||
farest = rtc_tm_to_time64(&tm_now) + rtc->rtcdev->alarm_offset_max;
|
||||
alarm = rtc_tm_to_time64(tm);
|
||||
if (time_after(alarm, farest))
|
||||
if (alarm > farest)
|
||||
return -ERANGE;
|
||||
|
||||
writel(bin2bcd(tm->tm_min), rtc->base + RZN1_RTC_ALM);
|
||||
|
||||
Reference in New Issue
Block a user