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

Make sure a BusInfo exists before trying to dereference it.

Signed-off-by: Joshua Housh <joshua.ho...@calxeda.com>
Signed-off-by: Mark Langsdorf <mark.langsd...@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 via email to