diff --git a/hw/pci.c b/hw/pci.c index f783362ae3..ef7607e177 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; }