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 8/9] PCI: of: Set fwnode device of newly created PCI device nodes
Date: Wed, 08 Jul 2026 10:43:08 +0000 [thread overview]
Message-ID: <20260708104309.0F3361F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708100302.517792-9-herve.codina@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The `fwnode->dev` pointer is not cleared in the error paths of `of_pci_make_dev_node()` and `of_pci_make_host_bridge_node()`, potentially leaving a dangling pointer.
--
--- Patch [8]: [PATCH v9 8/9] PCI: of: Set fwnode device of newly created PCI device nodes ---
commit deed8a4ace1f4465ff17d82fc17dc458281c89a1
Author: Herve Codina <herve.codina@bootlin.com>
PCI: of: Set fwnode device of newly created PCI device nodes
This commit sets the fwnode device field for dynamically created PCI
device nodes to prevent fw_devlink from incorrectly using the PCI root
bridge as a supplier. It ensures proper links are created by pointing
devlink directly to the PCI device.
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 8dd558a490bbd..ca83006b7c7e2 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
[ ... ]
> @@ -709,6 +710,13 @@ void of_pci_make_dev_node(struct pci_dev *pdev)
> if (ret)
> goto out_free_node;
>
> + /*
> + * Set the fwnode device in order to have fw_devlink creating links
> + * pointing to this PCI device instead of walking up to the PCI host
> + * bridge.
> + */
> + fw_devlink_set_device(&np->fwnode, &pdev->dev);
> +
> ret = of_changeset_apply(cset);
> if (ret)
> goto out_free_node;
[Severity: High]
If of_changeset_apply() fails here, the code jumps to the out_free_node
error path in of_pci_make_dev_node() without clearing the fwnode.dev
pointer that was just set.
If the node survives due to an external reference acquired during partial
application (such as from an OF_RECONFIG_ATTACH_NODE listener), could this
leave np->fwnode.dev pointing to &pdev->dev?
When the PCI device is later freed, does this result in a dangling pointer
and a potential use-after-free?
Should fw_devlink_set_device(&np->fwnode, NULL) be called in the error
handling path to safely undo the assignment?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708100302.517792-1-herve.codina@bootlin.com?part=8
next prev parent reply other threads:[~2026-07-08 10:43 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
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 [this message]
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=20260708104309.0F3361F000E9@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