Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Herve Codina" <herve.codina@bootlin.com>
Cc: linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v9 3/9] pinctrl: cs42l43: Use fw_devlink_set_device()
Date: Wed, 08 Jul 2026 10:20:29 +0000	[thread overview]
Message-ID: <20260708102029.E084E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708100302.517792-4-herve.codina@bootlin.com>

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

Pre-existing issues:
- [High] The driver overwrites the platform device's fwnode and devlink device pointer during probe, but fails to restore them on probe failure or driver unbind, leading to a Use-After-Free.
--

--- Patch [3]: [PATCH v9 3/9] pinctrl: cs42l43: Use fw_devlink_set_device() ---
commit 80d27bc87210331a635e646eedd21068256104a4
Author: Herve Codina <herve.codina@bootlin.com>

pinctrl: cs42l43: Use fw_devlink_set_device()

This patch updates the CS42L43 pinctrl driver to use the dedicated
fw_devlink_set_device() helper instead of directly modifying the fwnode->dev
field.

> diff --git a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> index 8990fab0446cf..563070aba3d81 100644
> --- a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> +++ b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> @@ -576,7 +576,7 @@ static int cs42l43_pin_probe(struct platform_device *pdev)
>  				return ret;
>  
>  			if (!child->dev)
> -				child->dev = priv->dev;
> +				fw_devlink_set_device(child, priv->dev);

[Severity: High]
This isn't a bug introduced by this patch, but could this setup leave a dangling
pointer that leads to a use-after-free on unbind?

If the device is instantiated via a Device Tree overlay, the driver fetches the
child node, takes a reference to it, and registers a devres action
(cs42l43_fwnode_put) to drop this reference on teardown.

Later in cs42l43_pin_probe(), the driver calls:

    device_set_node(priv->dev, fwnode);

This overwrites the platform device's fwnode with the child node without taking
an additional reference.

If the driver is unbound manually via sysfs or fails probe, the devres action
drops the driver's reference to the child node, but pdev->dev.fwnode is left
pointing to it. If the DT overlay is then removed, the OF core detaches the
node, causing the child node to be freed.

Finally, the OF core notifier triggers platform device removal, and
device_del() attempts to access dev->fwnode->dev to clear the devlink,
dereferencing the freed child node. 

Does this require a cleanup action to restore the original fwnode and devlink
device pointer on teardown?

>  			fwnode = child;
>  		}
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708100302.517792-1-herve.codina@bootlin.com?part=3

  reply	other threads:[~2026-07-08 10:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 10:02 [PATCH v9 0/9] lan966x pci device: Add support for SFPs, PCI part Herve Codina
2026-07-08 10:02 ` [PATCH v9 1/9] driver core: fw_devlink: Introduce fw_devlink_set_device() Herve Codina
2026-07-08 10:08   ` sashiko-bot
2026-07-08 10:02 ` [PATCH v9 2/9] drivers: core: Use fw_devlink_set_device() Herve Codina
2026-07-08 10:12   ` sashiko-bot
2026-07-08 10:02 ` [PATCH v9 3/9] pinctrl: cs42l43: " Herve Codina
2026-07-08 10:20   ` sashiko-bot [this message]
2026-07-08 10:02 ` [PATCH v9 4/9] cxl/test: Use device_set_node() Herve Codina
2026-07-08 10:15   ` sashiko-bot
2026-07-08 10:02 ` [PATCH v9 5/9] cxl/test: Use fw_devlink_set_device() Herve Codina
2026-07-08 10:16   ` sashiko-bot
2026-07-08 10:02 ` [PATCH v9 6/9] PCI: of: " Herve Codina
2026-07-08 10:29   ` sashiko-bot
2026-07-08 10:02 ` [PATCH v9 7/9] PCI: of: Clear fwnode->dev during root bridge node removal Herve Codina
2026-07-08 10:34   ` sashiko-bot
2026-07-08 10:02 ` [PATCH v9 8/9] PCI: of: Set fwnode device of newly created PCI device nodes Herve Codina
2026-07-08 10:43   ` sashiko-bot
2026-07-08 10:02 ` [PATCH v9 9/9] PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node Herve Codina
2026-07-08 10:48   ` 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=20260708102029.E084E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=herve.codina@bootlin.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox