Skip to content

Commit a29812a

Browse files
Hans Zhangbjorn-helgaas
authored andcommitted
PCI: mediatek: Protect root bus removal with rescan lock
Hold the pci_rescan_remove_lock lock while stopping and removing a root bus to avoid racing with concurrent rescan or hotplug operations triggered via sysfs. Such races may lead to use-after-free issues or system crashes. Signed-off-by: Hans Zhang <18255117159@163.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20260521161822.132996-7-18255117159@163.com
1 parent a6a64e1 commit a29812a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/pci/controller/pcie-mediatek.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,10 @@ static void mtk_pcie_remove(struct platform_device *pdev)
11721172
struct mtk_pcie *pcie = platform_get_drvdata(pdev);
11731173
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
11741174

1175+
pci_lock_rescan_remove();
11751176
pci_stop_root_bus(host->bus);
11761177
pci_remove_root_bus(host->bus);
1178+
pci_unlock_rescan_remove();
11771179
mtk_pcie_free_resources(pcie);
11781180

11791181
mtk_pcie_irq_teardown(pcie);

0 commit comments

Comments
 (0)