From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: linux-pci@vger.kernel.org, linux-amlogic@lists.infradead.org,
neil.armstrong@linaro.org
Subject: Re: [PATCH] PCI: meson: Fix potential use-after-free after PHY provider removal
Date: Wed, 18 Nov 2026 14:43:55 +0000 [thread overview]
Message-ID: <sashiko-outbox-221245@kernel.org> (raw)
In-Reply-To: <20261118-324f82bd41-pci-meson-0@mail.sdu.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] PCI: meson: open-coded device_link_add() on mp->phy->dev.parent
in meson_pcie_probe()
--
commit c65612b1d0d3578038649d0fdc61a7521f33e1fc
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
PCI: meson: Fix potential use-after-free after PHY provider removal
This commit adds a managed device link from the Meson PCIe device to its
PHY provider in meson_pcie_probe() so the PCIe controller is unbound
before the PHY provider releases its resources.
> diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
> index 8559d132dcde8..251673bc5963c 100644
> --- a/drivers/pci/controller/dwc/pci-meson.c
> +++ b/drivers/pci/controller/dwc/pci-meson.c
> @@ -401,6 +401,10 @@ static int meson_pcie_probe(struct platform_device *pdev)
> return PTR_ERR(mp->phy);
> }
>
> + if (!device_link_add(dev, mp->phy->dev.parent,
> + DL_FLAG_AUTOREMOVE_CONSUMER))
> + return dev_err_probe(dev, -EINVAL, "failed to link PHY provider\n");
[Severity: Low]
Should a PHY consumer driver reach into mp->phy->dev.parent to call
device_link_add() directly?
On Device Tree platforms, fw_devlink already parses the "phys" property
in drivers/of/property.c (parse_phys()) and creates a managed device
link between dev and the PHY provider, which causes
__device_release_driver() to unbind meson-pcie before the PHY provider
releases its devres resources; device_link_add() here just finds that
existing link and returns it without adding DL_FLAG_AUTOREMOVE_CONSUMER.
Reaching into struct phy internals also bypasses struct phy
encapsulation, and any provider device link needed when fw_devlink is
disabled belongs in the PHY core (phy_get() in drivers/phy/phy-core.c)
rather than in individual consumer drivers.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-324f82bd41-pci-meson-0@mail.sdu.edu.cn?part=1
prev parent reply other threads:[~2026-11-18 14:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 14:28 [PATCH] PCI: meson: Fix potential use-after-free after PHY provider removal Guangshuo Li
2026-11-18 14:43 ` 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=sashiko-outbox-221245@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=liguangshuo@mail.sdu.edu.cn \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=neil.armstrong@linaro.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