All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cosmo Chou" <chou.cosmo@gmail.com>
Cc: linux-rtc@vger.kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v2] rtc: pcf85363: Add error checking to regmap calls in probe()
Date: Fri, 17 Jul 2026 19:44:32 +0000	[thread overview]
Message-ID: <20260717194433.0DF211F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260717193705.2003175-1-chou.cosmo@gmail.com>

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

Pre-existing issues:
- [High] Concurrent probes modify a shared static nvmem_config array without synchronization, which can lead to memory corruption or use-after-free vulnerabilities.
--

--- Patch [1]: [PATCH v2] rtc: pcf85363: Add error checking to regmap calls in probe() ---
commit 5bd0f6fb9671f5eeb0aea5f9e2154781ed668ff5
Author: Cosmo Chou <chou.cosmo@gmail.com>

rtc: pcf85363: Add error checking to regmap calls in probe()

This commit propagates errors from unchecked regmap operations in the
probe() function using dev_err_probe() to prevent registering a
non-functional RTC device on I2C transport errors.

Link: https://lore.kernel.org/linux-rtc/20260716125142.1801599-1-chou.cosmo@gmail.com/

diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
index 540042b9eec8f..ccc7834e57599 100644
--- a/drivers/rtc/rtc-pcf85363.c
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -426,8 +426,8 @@ static int pcf85363_probe(struct i2c_client *client)
 
 	err = pcf85363_load_capacitance(pcf85363, client->dev.of_node);
 	if (err < 0)
-		dev_warn(&client->dev, "failed to set xtal load capacitance: %d",
-			 err);
+		return dev_err_probe(&client->dev, err,
+				     "failed to set xtal load capacitance\n");

[Severity: High]
This is a pre-existing issue, but since you are modifying the probe function,
could we look at a potential data race with the nvmem configuration?

In drivers/rtc/rtc-pcf85363.c:pcf85363_probe(), the nvmem_cfg array is
declared as static:

static int pcf85363_probe(struct i2c_client *client)
{
        ...
        static struct nvmem_config nvmem_cfg[] = {
                {
                        .name = "pcf85x63-",
                        ...
                },
        };

Later in the function, this globally shared array is mutated to set a 
per-instance priv pointer:

        for (i = 0; i < config->num_nvram; i++) {
                nvmem_cfg[i].priv = pcf85363;
                devm_rtc_nvmem_register(pcf85363->rtc, &nvmem_cfg[i]);
        }

If multiple instances of this device probe concurrently, can one instance
overwrite the priv and dev pointers of another instance? This might result
in one NVMEM device silently using the regmap and parent device of the
other instance, potentially leading to use-after-free and memory corruption
if the other device is unbound.

>  
>  	pcf85363->rtc->ops = &rtc_ops;
>  	pcf85363->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260717193705.2003175-1-chou.cosmo@gmail.com?part=1

      reply	other threads:[~2026-07-17 19:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 19:37 [PATCH v2] rtc: pcf85363: Add error checking to regmap calls in probe() Cosmo Chou
2026-07-17 19:44 ` 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=20260717194433.0DF211F000E9@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.