]> git.baikalelectronics.ru Git - kernel.git/commit
PCI: pciehp: Fix null pointer deref when hot-removing SR-IOV device
authorYinghai Lu <yinghai@kernel.org>
Fri, 19 Jul 2013 19:14:16 +0000 (12:14 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 25 Jul 2013 20:11:06 +0000 (14:11 -0600)
commitacf29d79e1f03b7bffadb614f2a4dd32d6674daf
treed8af2f85c7c5637f617f37112b74e5ec5c51596a
parent617537d2ebf9f8060e43c17ed9a7bf6d98b03f36
PCI: pciehp: Fix null pointer deref when hot-removing SR-IOV device

Hot-removing a device with SR-IOV enabled causes a null pointer dereference
in v3.9 and v3.10.

This is a regression caused by 88c44ad301 ("PCI: pciehp: Iterate over all
devices in slot, not functions 0-7").  When we iterate over the
bus->devices list, we first remove the PF, which also removes all the VFs
from the list.  Then the list iterator blows up because more than just the
current entry was removed from the list.

38503ad105 ("PCI: make sriov work with hotplug remove") works around a
similar problem in pci_stop_bus_devices() by iterating over the list in
reverse, so the VFs are stopped and removed from the list first, before the
PF.

This patch changes pciehp_unconfigure_device() to iterate over the list in
reverse, too.

[bhelgaas: bugzilla, changelog]
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=60604
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yijing Wang <wangyijing@huawei.com>
CC: stable@vger.kernel.org # v3.9+
drivers/pci/hotplug/pciehp_pci.c