From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, patches@linaro.org
Subject: [Qemu-devel] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails
Date: Wed, 3 Aug 2011 23:49:04 +0100 [thread overview]
Message-ID: <1312411744-9292-1-git-send-email-peter.maydell@linaro.org> (raw)
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
next reply other threads:[~2011-08-03 22:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 22:49 Peter Maydell [this message]
2011-08-04 6:55 ` [Qemu-devel] [PATCH] hw/qdev: Don't crash if qdev_create(NULL, ...) fails Markus Armbruster
2011-08-04 9:15 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1312411744-9292-1-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).