aboutsummaryrefslogtreecommitdiff
path: root/hw/ide/ioport.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2021-04-16 14:52:56 +0200
committerThomas Huth <thuth@redhat.com>2021-07-19 10:08:45 +0200
commit9405d87be25db6dff4d7b5ab48a81bbf6d083e47 (patch)
treec94429d30a760cfa44e04aad3c263e4a6f79bbbc /hw/ide/ioport.c
parent283f0a05e24a5e5fab78305f783f06215390d620 (diff)
hw/ide: Fix crash when plugging a piix3-ide device into the x-remote machine
QEMU currently crashes when the user tries to do something like: qemu-system-x86_64 -M x-remote -device piix3-ide This happens because the "isabus" variable is not initialized with the x-remote machine yet. Add a proper check for this condition and propagate the error to the caller, so we can fail there gracefully. Message-Id: <20210416125256.2039734-1-thuth@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'hw/ide/ioport.c')
-rw-r--r--hw/ide/ioport.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/hw/ide/ioport.c b/hw/ide/ioport.c
index b613ff3bba..e6caa537fa 100644
--- a/hw/ide/ioport.c
+++ b/hw/ide/ioport.c
@@ -50,15 +50,19 @@ static const MemoryRegionPortio ide_portio2_list[] = {
PORTIO_END_OF_LIST(),
};
-void ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2)
+int ide_init_ioport(IDEBus *bus, ISADevice *dev, int iobase, int iobase2)
{
+ int ret;
+
/* ??? Assume only ISA and PCI configurations, and that the PCI-ISA
bridge has been setup properly to always register with ISA. */
- isa_register_portio_list(dev, &bus->portio_list,
- iobase, ide_portio_list, bus, "ide");
+ ret = isa_register_portio_list(dev, &bus->portio_list,
+ iobase, ide_portio_list, bus, "ide");
- if (iobase2) {
- isa_register_portio_list(dev, &bus->portio2_list,
- iobase2, ide_portio2_list, bus, "ide");
+ if (ret == 0 && iobase2) {
+ ret = isa_register_portio_list(dev, &bus->portio2_list,
+ iobase2, ide_portio2_list, bus, "ide");
}
+
+ return ret;
}