From: sashiko-bot@kernel.org
To: "Cosmo Chou" <chou.cosmo@gmail.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
linux-rtc@vger.kernel.org
Subject: Re: [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware
Date: Thu, 16 Jul 2026 13:00:10 +0000 [thread overview]
Message-ID: <20260716130011.66BB61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716125142.1801599-1-chou.cosmo@gmail.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 the `nvmem_cfg` array in `pcf85363_probe()` is declared `static`, causing all instances of the device to share the same configuration. Because its `.id` field is not explicitly initialized, it defaults to 0 rather than `NVMEM_DEVID_AUTO`. The NVMEM core will assign ID 0 for the first instance (e.g., "pcf85x63-0"), but any subsequent PCF85363 device on the same system will cause a sysfs duplicate name collision and fail to register. Furthermore, the driver mutates this shared static structure during probe by assigning `nvmem_cfg[i].priv = pcf85363`, and the `devm_rtc_nvmem_register()` helper further mutates it by assigning `nvmem_config->dev = dev`. If two PCF85363 devices are probed concurrently, a data race occurs where one thread may overwrite the `priv` or `dev` pointers of the other before registration completes, causing NVMEM operations to access the wrong I2C device.
--
--- Patch [1]: [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware ---
commit ad427522054996520ae92d70a7e73f66bf7ac5a8
Author: Cosmo Chou <chou.cosmo@gmail.com>
rtc: pcf85363: Fix phantom device registration on missing hardware
This patch prevents phantom RTC device registration if the PCF85363 device
is missing. It propagates the error back to the driver core using
dev_err_probe() to properly abort the probe instead of continuing.
> diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
> --- a/drivers/rtc/rtc-pcf85363.c
> +++ b/drivers/rtc/rtc-pcf85363.c
> @@ -382,21 +382,21 @@ static int pcf85363_probe(struct i2c_client *client)
> {
> struct pcf85363 *pcf85363;
> const struct pcf85x63_config *config = &pcf_85363_config;
> const void *data = of_device_get_match_data(&client->dev);
> static struct nvmem_config nvmem_cfg[] = {
[Severity: High]
This is a pre-existing issue, but since nvmem_cfg is declared static, all
instances of the device share this configuration.
Because its .id field is not explicitly initialized, it defaults to 0
rather than NVMEM_DEVID_AUTO. Doesn't this cause sysfs duplicate name
collisions if multiple PCF85363 devices are present on the system?
Furthermore, doesn't this shared static array cause a data race during
concurrent probes? The driver mutates this array later in pcf85363_probe():
drivers/rtc/rtc-pcf85363.c:pcf85363_probe() {
...
for (i = 0; i < config->num_nvram; i++) {
nvmem_cfg[i].priv = pcf85363;
devm_rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg[i]);
...
}
And devm_rtc_nvmem_register() further mutates it by assigning
nvmem_config->dev = dev.
If two PCF85363 devices are probed concurrently, could one thread overwrite
the priv or dev pointers of the other before registration completes, causing
NVMEM operations to access the wrong I2C device? Should this configuration
be dynamically allocated or copied per-device instead of being static?
> {
> .name = "pcf85x63-",
> .word_size = 1,
> .stride = 1,
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716125142.1801599-1-chou.cosmo@gmail.com?part=1
prev parent reply other threads:[~2026-07-16 13:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 12:51 [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware Cosmo Chou
2026-07-16 12:56 ` Alexandre Belloni
2026-07-16 14:56 ` Cosmo Chou
2026-07-16 15:22 ` Alexandre Belloni
2026-07-16 13:00 ` 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=20260716130011.66BB61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=chou.cosmo@gmail.com \
--cc=linux-rtc@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.