summaryrefslogtreecommitdiff
path: root/hw/pci/pci.c
diff options
context:
space:
mode:
authorMarcel Apfelbaum <marcel.a@redhat.com>2014-10-27 19:34:42 +0200
committerMichael S. Tsirkin <mst@redhat.com>2014-11-02 13:44:12 +0200
commitdb80c7b974f4ccab56bd5e8ff2248c7339b00c73 (patch)
treef2f4b34fa63b51c032cc7dd2547f3173c2b2059c /hw/pci/pci.c
parent178e785fb4507ec3462dc772bbe08303416ece47 (diff)
hw/pci: fixed hotplug crash when using rombar=0 with devices having romfile
Hot-plugging a device that has a romfile (either supplied by user or built-in) using rombar=0 option is a user error, do not allow the device to be hot-plugged. Reviewed-by: Eric Blake <eblake@redhat.com> 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>
Diffstat (limited to 'hw/pci/pci.c')
-rw-r--r--hw/pci/pci.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 36226eb2c8..371699cf86 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1942,6 +1942,15 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
* for 0.11 compatibility.
*/
int class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
+
+ /*
+ * Hot-plugged devices can't use the option ROM
+ * if the rom bar is disabled.
+ */
+ if (DEVICE(pdev)->hotplugged) {
+ return -1;
+ }
+
if (class == 0x0300) {
rom_add_vga(pdev->romfile);
} else {