Message ID | 1312411744-9292-1-git-send-email-peter.maydell@linaro.org |
---|---|
State | Accepted |
Commit | e92714c71a2f50b8420126e952cadb653fa0ef93 |
Headers | show |
Peter Maydell <peter.maydell@linaro.org> writes: > If an attempt to create a qdev device on the default sysbus (by passing > NULL as the bus to qdev_create) fails, print a useful error message > rather than crashing trying to dereference a NULL pointer. The special case bus == NULL is ugly, and should be removed. But rejecting simple bug fixes because we want some cleanup would be blackmail, and only hurts users. Reviewed-by: Markus Armbruster <armbru@redhat.com>
On Wed, Aug 03, 2011 at 11:49:04PM +0100, Peter Maydell wrote: > If an attempt to create a qdev device on the default sysbus (by passing > NULL as the bus to qdev_create) fails, print a useful error message > rather than crashing trying to dereference a NULL pointer. > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> > --- > hw/qdev.c | 7 ++++++- > 1 files changed, 6 insertions(+), 1 deletions(-) Thanks, applied to the trivial patches tree: http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches-next Stefan
diff --git a/hw/qdev.c b/hw/qdev.c index b4ea8e1..3fec62a 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -110,7 +110,12 @@ DeviceState *qdev_create(BusState *bus, const char *name) dev = qdev_try_create(bus, name); if (!dev) { - hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name); + if (bus) { + hw_error("Unknown device '%s' for bus '%s'\n", name, + bus->info->name); + } else { + hw_error("Unknown device '%s' for default sysbus\n", name); + } } return dev;
If an attempt to create a qdev device on the default sysbus (by passing NULL as the bus to qdev_create) fails, print a useful error message rather than crashing trying to dereference a NULL pointer. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- hw/qdev.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)