From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
conor+dt@kernel.org, wsa+renesas@sang-engineering.com,
devicetree@vger.kernel.org, robh@kernel.org,
linux-rtc@vger.kernel.org
Subject: Re: [PATCH v2 05/10] rtc: rzn1: Fix alarm range check truncation on 32-bit systems
Date: Wed, 01 Jul 2026 14:45:43 +0000 [thread overview]
Message-ID: <20260701144544.044351F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701142953.2014895-6-prabhakar.mahadev-lad.rj@bp.renesas.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Alarm weekday calculation fails when crossing month boundaries, causing the alarm to be scheduled on the wrong day.
--
commit 461f51253cf0a8326dc4e0cd7278977b7ecc0fbd
Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
rtc: rzn1: Fix alarm range check truncation on 32-bit systems
This commit resolves the truncation of the alarm and farest timestamps on
32-bit systems. It achieves this by declaring these variables as time64_t
and replacing time_after() with a direct signed comparison.
> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 866ff595188d8..9969bcefede72 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
[ ... ]
> @@ -260,8 +261,8 @@ 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;
> unsigned int days_ahead, wday;
> + time64_t alarm, farest;
> int ret;
>
> ret = rzn1_rtc_read_time(dev, &tm_now);
> @@ -271,7 +272,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;
>
> /* Convert alarm day into week day */
[Severity: High]
This isn't a bug introduced by this patch, but I noticed a pre-existing
issue in how the weekday is calculated just below this in
rzn1_rtc_set_alarm().
When an alarm is set for the following month (for instance, setting an
alarm for the 1st of next month while today is the 31st), this calculation
is used:
days_ahead = tm->tm_mday - tm_now.tm_mday;
wday = (tm_now.tm_wday + days_ahead) % 7;
Since this only subtracts the day-of-month, wouldn't crossing a month
boundary result in a negative value (e.g., 1 - 31 = -30), which then
underflows the unsigned int days_ahead?
This would then result in an incorrect weekday offset being added to the
current weekday, programming the wrong weekday into the RZN1_RTC_ALW
register.
Should this logic be updated to safely handle month boundaries?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260701142953.2014895-1-prabhakar.mahadev-lad.rj@bp.renesas.com?part=5
next prev parent reply other threads:[~2026-07-01 14:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 14:29 [PATCH v2 00/10] Add RTC support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-07-01 14:29 ` [PATCH v2 01/10] dt-bindings: rtc: renesas,rzn1-rtc: Add RZ/T2H and RZ/N2H support Prabhakar
2026-07-01 14:35 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 02/10] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-07-01 14:39 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 03/10] rtc: rzn1: Fix malformed MODULE_AUTHOR string Prabhakar
2026-07-01 14:32 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 04/10] rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS Prabhakar
2026-07-01 14:39 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 05/10] rtc: rzn1: Fix alarm range check truncation on 32-bit systems Prabhakar
2026-07-01 14:45 ` sashiko-bot [this message]
2026-07-01 14:29 ` [PATCH v2 06/10] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate Prabhakar
2026-07-01 14:49 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 07/10] rtc: rzn1: Use temporary variable for struct device Prabhakar
2026-07-01 14:43 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 08/10] rtc: rzn1: Consistently use dev_err_probe() Prabhakar
2026-07-01 14:50 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 09/10] rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access Prabhakar
2026-07-01 14:48 ` sashiko-bot
2026-07-01 14:29 ` [PATCH v2 10/10] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-07-01 14:54 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701144544.044351F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=prabhakar.csengg@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox