hw/pci: fixed error flow in pci_qdev_init
authorMarcel Apfelbaum <marcel.a@redhat.com>
Mon, 27 Oct 2014 17:34:41 +0000 (19:34 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 2 Nov 2014 11:44:12 +0000 (13:44 +0200)
Verify return code for pci_add_option_rom.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
hw/pci/pci.c

index 6ce75aa9403d4fee5db32bc9b22f50ab77fa5903..36226eb2c8f4499656ad10f72071216506e59560 100644 (file)
@@ -1776,7 +1776,12 @@ static int pci_qdev_init(DeviceState *qdev)
         pci_dev->romfile = g_strdup(pc->romfile);
         is_default_rom = true;
     }
-    pci_add_option_rom(pci_dev, is_default_rom);
+
+    rc = pci_add_option_rom(pci_dev, is_default_rom);
+    if (rc != 0) {
+        pci_unregister_device(DEVICE(pci_dev));
+        return rc;
+    }
 
     return 0;
 }