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 v10 08/10] PCI: of: Set fwnode device of newly created PCI device nodes
Date: Fri, 17 Jul 2026 15:10:39 +0000	[thread overview]
Message-ID: <20260717151040.530CB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260717145147.823749-9-herve.codina@bootlin.com>

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

Pre-existing issues:
- [High] In `of_pci_remove_node`, a NULL pointer dereference or memory corruption occurs if the PCI device's device tree node was provided by a device tree overlay rather than `of_pci_make_dev_node`.
--

--- Patch [8]: [PATCH v10 08/10] PCI: of: Set fwnode device of newly created PCI device nodes ---
commit f4dcbb5e22115fd2e6073441c7d4ac5e66dae5c4
Author: Herve Codina <herve.codina@bootlin.com>

PCI: of: Set fwnode device of newly created PCI device nodes

This commit sets the fwnode device for PCI device nodes dynamically created 
by the PCI core. This ensures that fw_devlink creates correct links pointing
to the PCI device rather than walking up to the PCI host bridge when overlays
are applied.

> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 6a533f9bbf3c5..a98f360c289ae 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -657,6 +657,7 @@ void of_pci_remove_node(struct pci_dev *pdev)
>  	if (!np || !of_node_check_flag(np, OF_DYNAMIC))
>  		return;
>  
> +	fw_devlink_set_device(&np->fwnode, NULL);
>  	device_remove_of_node(&pdev->dev);

[Severity: High]
This is a pre-existing issue, but can this lead to a NULL pointer 
dereference or memory corruption if the device tree node was provided by 
a standard device tree overlay?

If a user applies a standard device tree overlay describing a PCI device, 
the newly created device node will have the OF_DYNAMIC flag set. When the 
PCI device is later removed (e.g., via PCIe hotplug or device unbind), 
of_pci_remove_node() will see the OF_DYNAMIC flag and execute these lines. 

However, since the node was created by a standard overlay and not 
by of_pci_make_dev_node(), np->data may be NULL or contain unrelated 
data. Is it safe to unconditionally pass np->data to of_changeset_revert() 
and of_changeset_destroy() here?

>  	of_changeset_revert(np->data);
>  	of_changeset_destroy(np->data);

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

  parent reply	other threads:[~2026-07-17 15:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 14:51 [PATCH v10 00/10] lan966x pci device: Add support for SFPs, PCI part Herve Codina
2026-07-17 14:51 ` [PATCH v10 01/10] driver core: fw_devlink: Introduce fw_devlink_set_device() Herve Codina
2026-07-17 14:58   ` sashiko-bot
2026-07-17 14:51 ` [PATCH v10 03/10] pinctrl: cs42l43: Use fw_devlink_set_device() Herve Codina
2026-07-17 15:05   ` sashiko-bot
2026-07-17 14:51 ` [PATCH v10 05/10] cxl/test: " Herve Codina
2026-07-17 14:58   ` sashiko-bot
2026-07-17 14:51 ` [PATCH v10 09/10] PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node Herve Codina
2026-07-17 17:08   ` sashiko-bot
     [not found] ` <20260717145147.823749-5-herve.codina@bootlin.com>
2026-07-17 14:59   ` [PATCH v10 04/10] cxl/test: Use device_set_node() sashiko-bot
     [not found] ` <20260717145147.823749-7-herve.codina@bootlin.com>
2026-07-17 15:03   ` [PATCH v10 06/10] PCI: of: Use fw_devlink_set_device() sashiko-bot
     [not found] ` <20260717145147.823749-8-herve.codina@bootlin.com>
2026-07-17 15:06   ` [PATCH v10 07/10] PCI: of: Clear fwnode->dev during root bridge node removal and error path sashiko-bot
     [not found] ` <20260717145147.823749-9-herve.codina@bootlin.com>
2026-07-17 15:10   ` sashiko-bot [this message]
     [not found] ` <20260717145147.823749-3-herve.codina@bootlin.com>
2026-07-17 15:12   ` [PATCH v10 02/10] drivers: core: Use fw_devlink_set_device() sashiko-bot
     [not found] ` <20260717145147.823749-11-herve.codina@bootlin.com>
2026-07-17 15:19   ` [PATCH v10 10/10] PCI: of: Guard against node removal with incorrect np->data 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=20260717151040.530CB1F000E9@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