[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/2] pci: Unregister BARs before device exit

From: Alex Williamson
Subject: [Qemu-devel] [PATCH 2/2] pci: Unregister BARs before device exit
Date: Tue, 03 Jul 2012 22:39:34 -0600
User-agent: StGIT/0.14.3

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 <address@hidden>

 hw/pci.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 8934722..1fc73f8 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -875,12 +875,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) {
-    pci_unregister_io_regions(pci_dev);
-    pci_del_option_rom(pci_dev);
     return 0;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]