* [Qemu-devel] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails
@ 2011-08-03 22:49 Peter Maydell
2011-08-04 6:55 ` Markus Armbruster
2011-08-04 9:15 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2011-08-03 22:49 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, patches
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(-)
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;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails
2011-08-03 22:49 [Qemu-devel] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails Peter Maydell
@ 2011-08-04 6:55 ` Markus Armbruster
2011-08-04 9:15 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2011-08-04 6:55 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-trivial, qemu-devel, patches
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails
2011-08-03 22:49 [Qemu-devel] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails Peter Maydell
2011-08-04 6:55 ` Markus Armbruster
@ 2011-08-04 9:15 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2011-08-04 9:15 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-trivial, qemu-devel, patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-04 9:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-03 22:49 [Qemu-devel] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails Peter Maydell
2011-08-04 6:55 ` Markus Armbruster
2011-08-04 9:15 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.