diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-10-18 14:41:33 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-10-19 23:13:28 +0200 |
commit | 675d717b9ee2d8dea9cfdca9aa69ed97d8bc54d3 (patch) | |
tree | e68cca66b002815129dbc633719bd22600a5e230 /hw | |
parent | 8a89bb060765e26e0f0d55a495caf3c0fd8615ba (diff) | |
download | qemu-675d717b9ee2d8dea9cfdca9aa69ed97d8bc54d3.zip qemu-675d717b9ee2d8dea9cfdca9aa69ed97d8bc54d3.tar.gz qemu-675d717b9ee2d8dea9cfdca9aa69ed97d8bc54d3.tar.bz2 |
hw/isa: Realize ISA bridge device before accessing it
qbus_new() should not be called on unrealized device.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20231019071611.98885-9-philmd@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/isa/isa-bus.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index a289ecc..f1e0f14 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -52,18 +52,25 @@ static const TypeInfo isa_bus_info = { ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space, MemoryRegion *address_space_io, Error **errp) { + DeviceState *bridge = NULL; + if (isabus) { error_setg(errp, "Can't create a second ISA bus"); return NULL; } if (!dev) { - dev = qdev_new("isabus-bridge"); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + bridge = qdev_new("isabus-bridge"); + dev = bridge; } isabus = ISA_BUS(qbus_new(TYPE_ISA_BUS, dev, NULL)); isabus->address_space = address_space; isabus->address_space_io = address_space_io; + + if (bridge) { + sysbus_realize_and_unref(SYS_BUS_DEVICE(bridge), &error_fatal); + } + return isabus; } |