cxl: use pcibios_free_controller_deferred() when removing vPHBs
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Thu, 18 Aug 2016 07:35:14 +0000 (17:35 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Oct 2016 15:50:36 +0000 (17:50 +0200)
commit3e08bc37a172aed688ddb45d0d5c54c65464a079
tree519e455b16b3ec2908e35f991ba55c7d65c97847
parent83573addff2b4e16df9fad9a561a0d77d554b370
cxl: use pcibios_free_controller_deferred() when removing vPHBs

commit 6f38a8b9a45833495dc878c335c5431cd98a16ed upstream.

When cxl removes a vPHB, it's possible that the pci_controller may be freed
before all references to the devices on the vPHB have been released. This
in turn causes an invalid memory access when the devices are eventually
released, as pcibios_release_device() attempts to call the phb's
release_device hook.

In cxl_pci_vphb_remove(), remove the existing call to
pcibios_free_controller(). Instead, use
pcibios_free_controller_deferred() to free the pci_controller after all
devices have been released. Export pci_set_host_bridge_release() so we can
do this.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/cxl/vphb.c
drivers/pci/host-bridge.c