Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: meson: Fix potential use-after-free after PHY provider removal
@ 2026-11-18 14:28 Guangshuo Li
  2026-11-18 14:43 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-18 14:28 UTC (permalink / raw)
  To: Yue Wang, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl
  Cc: linux-pci, linux-amlogic, linux-arm-kernel, linux-kernel

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@mail.sdu.edu.cn>
---
 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


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox