[d/azure][PATCH 2/2] UBUNTU: SAUCE: PCI: hv: Fix panic by calling hv_pci_remove_slots() earlier

Marcelo Henrique Cerri marcelo.cerri at canonical.com
Thu Aug 8 15:34:53 UTC 2019

From: Dexuan Cui <decui at microsoft.com>

BugLink: https://bugs.launchpad.net/bugs/1837661

The slot must be removed before the pci_dev is removed, otherwise a panic
can happen due to use-after-free.

Fixes: 15becc2b56c6 ("PCI: hv: Add hv_pci_remove_slots() when we unload the driver")
Signed-off-by: Dexuan Cui <decui at microsoft.com>
Cc: stable at vger.kernel.org
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri at canonical.com>
 drivers/pci/controller/pci-hyperv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index ae91e708796f..3bd94149b9d2 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -2714,8 +2714,8 @@ static int hv_pci_remove(struct hv_device *hdev)
 		/* Remove the bus from PCI's point of view. */
-		pci_remove_root_bus(hbus->pci_bus);
+		pci_remove_root_bus(hbus->pci_bus);
 		hbus->state = hv_pcibus_removed;

More information about the kernel-team mailing list