From: Stefan Weil Date: Thu, 16 Dec 2010 18:33:22 +0000 (+0100) Subject: qdev: sysbus_get_default must not return a NULL pointer (fix regression) X-Git-Tag: TizenStudio_2.0_p2.3~3756 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0669b69c7b15e27ba07ae405298caf9ba7101013;p=sdk%2Femulator%2Fqemu.git 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 Signed-off-by: Stefan Weil Signed-off-by: Aurelien Jarno --- diff --git a/hw/qdev.c b/hw/qdev.c index 10e28df..6fc9b02 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -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; }