diff options
author | Stefan Weil <weil@mail.berlios.de> | 2010-12-16 19:33:22 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2010-12-19 14:06:17 +0200 |
commit | 68694897e55ebd229898d4b6546877ccea500954 (patch) | |
tree | 0853f00172ef7411e9f692846e49ce258955f04f | |
parent | af0669f0edbbcb8c17f7c2b919089485c8327f4f (diff) |
qdev: sysbus_get_default must not return a NULL pointer (fix regression)
Every system should have some sort of main system bus,
so sysbus_get_default should always return a valid bus.
Without this patch, at least mipssim and malta no longer
start but raise a null pointer access exception (caused by
commit ec990eb622ad46df5ddcb1e94c418c271894d416).
Cc: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | hw/qdev.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -107,10 +107,7 @@ DeviceState *qdev_create(BusState *bus, const char *name) DeviceInfo *info; if (!bus) { - if (!main_system_bus) { - main_system_bus = qbus_create(&system_bus_info, NULL, "main-system-bus"); - } - bus = main_system_bus; + bus = sysbus_get_default(); } info = qdev_find_info(bus->info, name); @@ -311,6 +308,10 @@ static int qdev_reset_one(DeviceState *dev, void *opaque) BusState *sysbus_get_default(void) { + if (!main_system_bus) { + main_system_bus = qbus_create(&system_bus_info, NULL, + "main-system-bus"); + } return main_system_bus; } |