Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heiko Schocher" <hs@nabladev.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	conor+dt@kernel.org, linux-rtc@vger.kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 3/3] rtc: rs5c372: support eco mode on R2223x
Date: Tue, 25 Aug 2026 07:36:52 +0000	[thread overview]
Message-ID: <20260825073653.19CAD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825071927.4090460-4-hs@nabladev.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but missing RTC range_min and range_max constraints allow user-space to inject dates prior to year 2000, causing an integer underflow in bin2bcd() and silent RTC corruption.
--

--- Patch [3]: [PATCH v2 3/3] rtc: rs5c372: support eco mode on R2223x ---
commit dde76823d322a057d0dc319ae14408d7646ff056
Author: Heiko Schocher <hs@nabladev.com>

rtc: rs5c372: support eco mode on R2223x

The R2223x can run in an eco mode that lowers its current consumption from the
backup supply. This patch adds support for configuring this mode via the
ricoh,eco-mode device tree property.

> diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
> index c65b76cc0dc66..9ab6f2c28f7b1 100644
> --- a/drivers/rtc/rtc-rs5c372.c
> +++ b/drivers/rtc/rtc-rs5c372.c

[ ... ]

> @@ -903,6 +922,15 @@ static int rs5c372_probe(struct i2c_client *client)
>  			rs5c372->time24 ? "24hr" : "am/pm"
>  			);
>  
> +	if (rs5c372->type == rtc_r2223x) {
> +		bool eco = device_property_read_bool(&client->dev,
> +						     "ricoh,eco-mode");
> +
> +		err = rs5c372_set_eco_mode(rs5c372, eco);
> +		if (err < 0)
> +			goto exit;
> +	}
> +
>  	/* REVISIT use client->irq to register alarm irq ... */
>  	rs5c372->rtc = devm_rtc_device_register(&client->dev,
>  					rs5c372_driver.driver.name,

[Severity: High]
This isn't a bug introduced by this patch, but should the RTC range_min and
range_max constraints be explicitly initialized here before registration?

The core RTC subsystem defaults range_min to 1970 if not set by the driver,
allowing user-space to set tm_year between 70 and 99. Inside
rs5c372_rtc_set_time(), the driver computes tm->tm_year - 100, which
underflows to a negative number when tm_year < 100:

drivers/rtc/rtc-rs5c372.c:rs5c372_rtc_set_time() {
    ...
    buf[6] = bin2bcd(tm->tm_year - 100);
    ...
}

This results in an incorrectly shifted BCD value being written to the I2C RTC
register, silently corrupting the RTC time with garbage future dates when a
valid standard date is requested.

>  					&rs5c372_rtc_ops, THIS_MODULE);
>  
>  	if (IS_ERR(rs5c372->rtc)) {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260825071927.4090460-1-hs@nabladev.com?part=3

      reply	other threads:[~2026-08-25  7:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  7:19 [PATCH v2 0/3] rtc: rs5c372: add Ricoh R2223x support Heiko Schocher
2026-08-25  7:19 ` [PATCH v2 1/3] dt-bindings: rtc: add ricoh,r2223x binding Heiko Schocher
2026-08-25  7:24   ` sashiko-bot
2026-08-25  7:19 ` [PATCH v2 2/3] rtc: rs5c372: add support for Ricoh R2223x Heiko Schocher
2026-08-25  7:35   ` sashiko-bot
2026-08-25  7:19 ` [PATCH v2 3/3] rtc: rs5c372: support eco mode on R2223x Heiko Schocher
2026-08-25  7:36   ` sashiko-bot [this message]

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=20260825073653.19CAD1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hs@nabladev.com \
    --cc=linux-rtc@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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