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>
This commit is contained in:
parent
178e785fb4
commit
db80c7b974
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user