Linux RTC
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Probst" <markus.probst@posteo.de>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	linux-rtc@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v9 4/6] rtc: s35390a: Read 24-hour mode on access
Date: Wed, 16 Sep 2026 16:10:21 +0000	[thread overview]
Message-ID: <20260916161021.D9C4E1F00899@smtp.kernel.org> (raw)
In-Reply-To: <20260916-rtc_s35390a_int1-v9-4-b2567a3e4959@posteo.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] rtc: s35390a: read_alarm destructively clears pending interrupts and power-loss flags
--

commit ca86574fc774e3c6f6f2d2629b0a0ab8635be21f
Author: Markus Probst <markus.probst@posteo.de>

rtc: s35390a: Read 24-hour mode on access

This patch modifies the s35390a driver to read the 24-hour mode flag
dynamically on access rather than caching it during probe. It aims to prevent
out-of-sync issues when the chip is reset while in 12-hour mode.

> diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> index 575bb256eb258..12ed504db94d8 100644
> --- a/drivers/rtc/rtc-s35390a.c
> +++ b/drivers/rtc/rtc-s35390a.c
[ ... ]
> @@ -345,14 +350,20 @@ static int s35390a_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
>  	struct s35390a *s35390a = i2c_get_clientdata(client);
> -	u8 buf[3], sts;
> +	u8 buf[3], status1, status2;
>  	int i, err;
>  
> -	err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
> +	err = s35390a_read_status(s35390a, &status1);

[Severity: High]
Does this new s35390a_read_status() call destructively clear pending interrupts
and power-loss flags?

When s35390a_read_status() executes, it issues an I2C read against the
S35390A_CMD_STATUS1 register. According to the S-35390A hardware behavior,
reading STATUS1 automatically clears the POC (Power-On Clear), BLD (Battery Low
Detection), INT1, and INT2 flags.

Because s35390a_rtc_read_alarm() does not handle these flags after reading
STATUS1, it appears this would inadvertently erase any pending alarm wake-up
events and silently discard power-loss faults. 

Since reading an alarm can be triggered by unprivileged user-space applications
via sysfs or RTC ioctls, could this allow a trivial denial of service for RTC
alarms and power-loss detection?

> +	if (err == 1)
> +		return -EINVAL;
> +	if (err < 0)
> +		return err;
> +
> +	err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &status2, sizeof(status2));
>  	if (err < 0)
>  		return err;
>  
> -	if ((sts & S35390A_INT2_MODE_MASK) != S35390A_INT2_MODE_ALARM) {
> +	if ((status2 & S35390A_INT2_MODE_MASK) != S35390A_INT2_MODE_ALARM) {
>  		/*
>  		 * When the alarm isn't enabled, the register to configure
>  		 * the alarm time isn't accessible.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916-rtc_s35390a_int1-v9-0-b2567a3e4959@posteo.de?part=4

  reply	other threads:[~2026-09-16 16:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 16:00 [PATCH v9 0/6] rtc: s35390a: Allow use of output pin for interrupt signal 1 for wakealarm Markus Probst
2026-09-16 16:00 ` [PATCH v9 1/6] dt-bindings: rtc: Add pinctrl for S35390A Markus Probst
2026-09-16 16:07   ` sashiko-bot
2026-09-24 22:02   ` Rob Herring
2026-09-16 16:00 ` [PATCH v9 2/6] rtc: s35390a: Add missing newline to dev_err Markus Probst
2026-09-16 16:04   ` sashiko-bot
2026-09-16 16:00 ` [PATCH v9 3/6] rtc: s35390a: Fix alarm not disabling Markus Probst
2026-09-16 16:13   ` sashiko-bot
2026-09-16 16:00 ` [PATCH v9 4/6] rtc: s35390a: Read 24-hour mode on access Markus Probst
2026-09-16 16:10   ` sashiko-bot [this message]
2026-09-16 16:00 ` [PATCH v9 5/6] rtc: s35390a: Add pinctrl Markus Probst
2026-09-16 16:12   ` sashiko-bot
2026-09-16 16:00 ` [PATCH v9 6/6] rtc: s35390a: Add synology quirk Markus Probst
2026-09-16 16:05   ` 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=20260916161021.D9C4E1F00899@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=markus.probst@posteo.de \
    --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