[PATCH] PCI: meson: Fix potential use-after-free after PHY provider removal
From: Guangshuo Li
Date: Wed Nov 18 2026 - 09:28:38 EST
The PHY reference keeps the PHY device alive, but not the provider
driver resources used by its callbacks. Without a managed dependency,
unbinding the provider first can leave meson_pcie_power_off() accessing
freed provider data during PCIe removal.
Add a managed link to the PHY provider so the PCIe controller is unbound
before the provider releases its resources.
This issue was found by our static analysis tool under development.
Fixes: 4b0dc84b2939 ("PCI: meson: Add missing remove callback")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/pci/controller/dwc/pci-meson.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
index 8559d132dcde..251673bc5963 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");
+
mp->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(mp->reset_gpio)) {
dev_err(dev, "get reset gpio failed\n");
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0