From: sashiko-bot@kernel.org
To: "Markus Probst" <markus.probst@posteo.de>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org,
linux-rtc@vger.kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v6 4/6] rtc: s35390a: Read 24-hour mode on access
Date: Sun, 23 Aug 2026 22:24:40 +0000 [thread overview]
Message-ID: <20260823222440.BF1541F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824-rtc_s35390a_int1-v6-4-df96569e3412@posteo.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Uninitialized stack variable usage due to missing error check for negative return values from s35390a_read_status.
--
--- Patch [4]: [PATCH v6 4/6] rtc: s35390a: Read 24-hour mode on access ---
commit d45935347291ea27eb3558322c8f56d965fd15e6
Author: Markus Probst <markus.probst@posteo.de>
rtc: s35390a: Read 24-hour mode on access
This commit reads the 24-hour mode on access instead of only on probe. It
fixes time corruption when resetting the chip in 12-hour mode, as
s35390a_init did not update the cached value.
> diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> index 575bb256eb258..8e3616c65d2c0 100644
> --- a/drivers/rtc/rtc-s35390a.c
> +++ b/drivers/rtc/rtc-s35390a.c
[ ... ]
> @@ -256,7 +258,7 @@ static int s35390a_rtc_read_time(struct device *dev, struct rtc_time *tm)
>
> tm->tm_sec = bcd2bin(buf[S35390A_BYTE_SECS]);
> tm->tm_min = bcd2bin(buf[S35390A_BYTE_MINS]);
> - tm->tm_hour = s35390a_reg2hr(s35390a, buf[S35390A_BYTE_HOURS]);
> + tm->tm_hour = s35390a_reg2hr(buf[S35390A_BYTE_HOURS], status & S35390A_FLAG_24H);
[Severity: High]
Earlier in s35390a_rtc_read_time(), the code calls
s35390a_read_status(s35390a, &status).
If this call fails with a negative error code (e.g. -EIO due to a transient
I2C error), the check if (s35390a_read_status(s35390a, &status) == 1) evaluates
to false, and the function proceeds without returning an error.
Will this cause the uninitialized status stack variable to be evaluated here,
potentially corrupting the time calculation?
[ ... ]
> @@ -345,14 +347,17 @@ 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));
> + if (s35390a_read_status(s35390a, &status1) == 1)
> + return -EINVAL;
> +
> + err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &status2, sizeof(status2));
> if (err < 0)
> return err;
[ ... ]
> @@ -381,8 +386,8 @@ static int s35390a_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
>
> if (buf[S35390A_ALRM_BYTE_HOURS] & 0x80)
> alm->time.tm_hour =
> - s35390a_reg2hr(s35390a,
> - buf[S35390A_ALRM_BYTE_HOURS] & ~0x80);
> + s35390a_reg2hr(buf[S35390A_ALRM_BYTE_HOURS] & ~0x80,
> + status1 & S35390A_FLAG_24H);
[Severity: High]
Similarly to s35390a_rtc_read_time(), if s35390a_read_status() returns a
negative error code, the check above will pass and the status1 stack variable
will remain uninitialized.
Could this allow the uninitialized status1 variable to be used here to determine
the alarm hour calculations?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-rtc_s35390a_int1-v6-0-df96569e3412@posteo.de?part=4
next prev parent reply other threads:[~2026-08-23 22:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 22:13 [PATCH v6 0/6] rtc: s35390a: Allow use of output pin for interrupt signal 1 for wakealarm Markus Probst
2026-08-23 22:13 ` [PATCH v6 1/6] dt-bindings: rtc: Add pinctrl for S35390A Markus Probst
2026-08-23 22:20 ` sashiko-bot
2026-08-23 22:13 ` [PATCH v6 2/6] rtc: s35390a: Add missing newline to dev_err Markus Probst
2026-08-23 22:21 ` sashiko-bot
2026-08-25 19:25 ` Linus Walleij
2026-08-23 22:13 ` [PATCH v6 3/6] rtc: s35390a: Fix alarm not disabling Markus Probst
2026-08-23 22:19 ` sashiko-bot
2026-08-23 22:13 ` [PATCH v6 4/6] rtc: s35390a: Read 24-hour mode on access Markus Probst
2026-08-23 22:24 ` sashiko-bot [this message]
2026-08-23 22:13 ` [PATCH v6 5/6] rtc: s35390a: Add pinctrl Markus Probst
2026-08-23 22:26 ` sashiko-bot
2026-08-25 19:28 ` Linus Walleij
2026-08-25 19:36 ` Markus Probst
2026-08-25 19:39 ` Markus Probst
2026-08-23 22:13 ` [PATCH v6 6/6] rtc: s35390a: Add synology quirk Markus Probst
2026-08-23 22:18 ` 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=20260823222440.BF1541F000E9@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