aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2012-07-03 22:39:34 -0600
committerMichael S. Tsirkin <mst@redhat.com>2012-07-04 15:55:07 +0300
commit7cf1b0fd95657e722b2ad290649eee88d1365786 (patch)
treea3a32e78cb8a50b0de6955f798291ec277b13dc9
parentf90c2bcdbc69e41e575f868b984c3e2de8f51bac (diff)
downloadqemu-7cf1b0fd95657e722b2ad290649eee88d1365786.zip
qemu-7cf1b0fd95657e722b2ad290649eee88d1365786.tar.gz
qemu-7cf1b0fd95657e722b2ad290649eee88d1365786.tar.bz2
pci: Unregister BARs before device exit
BARs are registered in init functions from memory regions created by the drivers. Exit functions destroy those memory regions. By unregistering the io regions after exit(), we're calling memory_region_del_subregion on freed memory. Don't do that. The option rom comes along for the ride because it's more symmetric to how it's created. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/pci.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/hw/pci.c b/hw/pci.c
index f783362..ef7607e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -838,12 +838,13 @@ static int pci_unregister_device(DeviceState *dev)
PCIDevice *pci_dev = PCI_DEVICE(dev);
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
+ pci_unregister_io_regions(pci_dev);
+ pci_del_option_rom(pci_dev);
+
if (pc->exit) {
pc->exit(pci_dev);
}
- pci_unregister_io_regions(pci_dev);
- pci_del_option_rom(pci_dev);
do_pci_unregister_device(pci_dev);
return 0;
}