diff --git a/hw/pci.c b/hw/pci.c
index 7787005..7e5c539 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -650,6 +650,7 @@ static void do_pci_unregister_device(PCIDevice *pci_dev)
     qemu_free_irqs(pci_dev->irq);
     pci_dev->bus->devices[pci_dev->devfn] = NULL;
     pci_config_free(pci_dev);
+    qemu_free(pci_dev->romfile);
 }
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
