From: sashiko-bot@kernel.org
To: "Markus Probst" <markus.probst@posteo.de>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org,
linux-rtc@vger.kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v8 5/6] rtc: s35390a: Add pinctrl
Date: Mon, 31 Aug 2026 21:00:33 +0000 [thread overview]
Message-ID: <20260831210033.CD5F51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831-rtc_s35390a_int1-v8-5-dac1dc86ce1f@posteo.de>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Hardware reset clears persistent pinctrl pin configurations without restoring them, breaking clock outputs.
- [Medium] Lockless read of `s35390a->pinfunction` introduces a TOCTOU race with concurrent pinctrl consumers, potentially overwriting valid pinmux configurations with fallbacks.
--
commit b6394d0bf7b85783daa05f6575f0b6579cf01843
Author: Markus Probst <markus.probst@posteo.de>
Subject: rtc: s35390a: Add pinctrl
This commit adds pinctrl support to the s35390a RTC driver, allowing
the configuration of pin functions like wake-up, minute periodic interrupt,
or disabling the output. It falls back to previous behavior if no function
is configured.
> diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> --- a/drivers/rtc/rtc-s35390a.c
> +++ b/drivers/rtc/rtc-s35390a.c
[ ... ]
> @@ -64,6 +89,10 @@ MODULE_DEVICE_TABLE(of, s35390a_of_match);
>
> struct s35390a {
> struct i2c_client *client[8];
> + struct rtc_device *rtc;
> +
> + struct mutex pinfunction_lock; /* lock preventing concurrent access of pin function */
> + int pinfunction[2];
> };
[Severity: High]
If a user triggers a hardware reset at runtime via the RTC_VL_CLR ioctl,
it calls s35390a_init() which completely clears the STATUS2 register:
drivers/rtc/rtc-s35390a.c:s35390a_rtc_ioctl() {
...
case RTC_VL_CLR:
/* update flag and clear register */
err = s35390a_init(s35390a, &sts);
...
}
drivers/rtc/rtc-s35390a.c:s35390a_init() {
...
*sts = S35390A_FLAG_RESET | S35390A_FLAG_24H;
ret = s35390a_set_reg(s35390a, S35390A_CMD_STATUS1, sts, 1);
...
}
Because s35390a->pinfunction retains the previously configured pinctrl
state but the hardware has been reset, will this permanently break the
pinctrl outputs (such as PMIN clock outputs) since the software and
hardware are now out of sync?
[ ... ]
> @@ -539,9 +762,33 @@ static int s35390a_probe(struct i2c_client *client)
[ ... ]
> + err = pinctrl_enable(pctl);
> + if (err)
> + return dev_err_probe(dev, err, "pinctrl enable failed\n");
> +
> + /* If no pinmux function is defined in DT, fallback to previous behaviour */
> + fallback[0] = S35390A_FUNC_IGNORE;
> + fallback[1] = S35390A_FUNC_WAKEUP;
> +
> + for (i = 0; i < ARRAY_SIZE(s35390a_pin_groups); i++) {
> + if (s35390a->pinfunction[i] == -1) {
> + err = s35390a_pinctrl_set_mux(pctl, fallback[i], i);
[Severity: Medium]
Since pinctrl_enable() makes the pinctrl device globally visible before
this loop runs, is there a TOCTOU race condition if a consumer driver
requests a pin state concurrently?
If a consumer (e.g., probing asynchronously) sets the hardware state and
updates pinfunction right before the lockless s35390a->pinfunction[i] == -1
check evaluates to true, could this probe thread subsequently acquire the
lock and overwrite the explicitly requested configuration with the fallback
state?
> + if (err)
> + return err;
> + }
> + }
> +
> nvmem_cfg.priv = s35390a;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-rtc_s35390a_int1-v8-0-dac1dc86ce1f@posteo.de?part=5
next prev parent reply other threads:[~2026-08-31 21:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 17:42 [PATCH v8 0/6] rtc: s35390a: Allow use of output pin for interrupt signal 1 for wakealarm Markus Probst
2026-08-31 17:42 ` [PATCH v8 1/6] dt-bindings: rtc: Add pinctrl for S35390A Markus Probst
2026-08-31 19:52 ` sashiko-bot
2026-08-31 19:54 ` Markus Probst
2026-09-01 10:05 ` Krzysztof Kozlowski
2026-09-01 13:28 ` Markus Probst
2026-09-03 9:35 ` Krzysztof Kozlowski
2026-08-31 17:42 ` [PATCH v8 2/6] rtc: s35390a: Add missing newline to dev_err Markus Probst
2026-08-31 19:57 ` sashiko-bot
2026-08-31 17:42 ` [PATCH v8 3/6] rtc: s35390a: Fix alarm not disabling Markus Probst
2026-08-31 20:14 ` sashiko-bot
2026-08-31 17:42 ` [PATCH v8 4/6] rtc: s35390a: Read 24-hour mode on access Markus Probst
2026-08-31 20:24 ` sashiko-bot
2026-08-31 17:42 ` [PATCH v8 5/6] rtc: s35390a: Add pinctrl Markus Probst
2026-08-31 21:00 ` sashiko-bot [this message]
2026-08-31 17:42 ` [PATCH v8 6/6] rtc: s35390a: Add synology quirk Markus Probst
2026-08-31 21:06 ` 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=20260831210033.CD5F51F000E9@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