Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Robert Marko" <robert.marko@sartura.hr>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org,
	krzk+dt@kernel.org
Subject: Re: [PATCH v3 2/3] nvmem: lan9662-otp: add support for LAN969x
Date: Fri, 15 May 2026 12:31:35 +0000	[thread overview]
Message-ID: <20260515123136.3A843C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260515115954.701155-2-robimarko@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The driver mutates a shared static global structure (`otp_config`) during its `probe()` function, creating a data race on concurrent probes.
--

commit 084765687704216b34f261a961d208c0c6497f50
Author: Horatiu Vultur <horatiu.vultur@microchip.com>

nvmem: lan9662-otp: add support for LAN969x

This commit adds support for the Microchip LAN969x to the lan9662-otp driver.
It relies on the existing control logic while allowing the OTP size to vary
based on device tree match data.

> diff --git a/drivers/nvmem/lan9662-otpc.c b/drivers/nvmem/lan9662-otpc.c
> index 56fc19f092a7f..62d1d6381bf88 100644
> --- a/drivers/nvmem/lan9662-otpc.c
> +++ b/drivers/nvmem/lan9662-otpc.c

[ ... ]

> @@ -196,6 +194,7 @@ static int lan9662_otp_probe(struct platform_device *pdev)
>  
>  	otp_config.priv = otp;
>  	otp_config.dev = dev;
> +	otp_config.size = (uintptr_t) device_get_match_data(dev);

Does modifying the static otp_config structure during probe create a data
race?

If multiple device instances are probed concurrently, threads could race to
update these fields. This could lead to one instance being registered with
another's private data before devm_nvmem_register() creates its internal
copy.

If that happens and the latter device is unbound, its devm-managed memory is
freed, which could result in a use-after-free when the first device attempts
to access the nvmem interface.

Would it be safer to allocate the nvmem_config structure locally on the
stack within the probe function instead of using a global static structure?

>  
>  	nvmem = devm_nvmem_register(dev, &otp_config);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515115954.701155-1-robimarko@gmail.com?part=2

  reply	other threads:[~2026-05-15 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 11:59 [PATCH v3 1/3] dt-bindings: nvmem: lan9662-otpc: Add LAN969x series Robert Marko
2026-05-15 11:59 ` [PATCH v3 2/3] nvmem: lan9662-otp: add support for LAN969x Robert Marko
2026-05-15 12:31   ` sashiko-bot [this message]
2026-05-15 11:59 ` [PATCH v3 3/3] arm64: dts: microchip: lan969x: add OTP node Robert Marko

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=20260515123136.3A843C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=robert.marko@sartura.hr \
    --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