diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index ef8b18c48f2641993f56aa643ed8a35579856971..82f8ae572703b1542134d04e55eb5bc74b4bb7b7 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -144,7 +144,15 @@ static void pci_stop_bus_devices(struct pci_bus *bus)
 {
 	struct list_head *l, *n;
 
-	list_for_each_safe(l, n, &bus->devices) {
+	/*
+	 * VFs could be removed by pci_remove_bus_device() in the
+	 *  pci_stop_bus_devices() code path for PF.
+	 *  aka, bus->devices get updated in the process.
+	 * but VFs are inserted after PFs when SRIOV is enabled for PF,
+	 * We can iterate the list backwards to get prev valid PF instead
+	 *  of removed VF.
+	 */
+	list_for_each_prev_safe(l, n, &bus->devices) {
 		struct pci_dev *dev = pci_dev_b(l);
 		pci_stop_bus_device(dev);
 	}