qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark Langsdorf <mark.langsdorf@calxeda.com>
To: qemu-devel@nongnu.org
Cc: Joshua Housh <joshua.housh@calxeda.com>,
	aliguori@us.ibm.com, paul@codesourcery.com,
	Mark Langsdorf <mark.langsdorf@calxeda.com>
Subject: [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference
Date: Tue, 13 Mar 2012 13:32:27 -0500	[thread overview]
Message-ID: <1331663547-30041-1-git-send-email-mark.langsdorf@calxeda.com> (raw)

From: Joshua Housh <joshua.housh@calxeda.com>

Make sure a BusInfo exists before trying to dereference it.

Signed-off-by: Joshua Housh <joshua.housh@calxeda.com>
Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>
---
 hw/qdev.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index ee21d90..6c3d02f 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -86,9 +86,12 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
     dev->parent_bus = bus;
     QTAILQ_INSERT_HEAD(&bus->children, dev, sibling);
 
-    for (prop = qdev_get_bus_info(dev)->props; prop && prop->name; prop++) {
-        qdev_property_add_legacy(dev, prop, NULL);
-        qdev_property_add_static(dev, prop, NULL);
+    BusInfo *info = qdev_get_bus_info(dev);
+    if (info) {
+        for (prop = info->props; prop && prop->name; prop++) {
+            qdev_property_add_legacy(dev, prop, NULL);
+            qdev_property_add_static(dev, prop, NULL);
+        }
     }
     qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
 }
-- 
1.7.5.4

             reply	other threads:[~2012-03-13 18:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13 18:32 Mark Langsdorf [this message]
2012-03-13 18:55 ` [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference Andreas Färber
2012-03-14  7:59   ` Markus Armbruster
2012-03-14 14:30     ` Andreas Färber

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=1331663547-30041-1-git-send-email-mark.langsdorf@calxeda.com \
    --to=mark.langsdorf@calxeda.com \
    --cc=aliguori@us.ibm.com \
    --cc=joshua.housh@calxeda.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@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).