aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/qdev.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index f2c2484..e2a5c57 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -698,16 +698,18 @@ static void device_class_base_init(ObjectClass *class, void *data)
klass->props = NULL;
}
-static void qdev_remove_from_bus(Object *obj)
+static void device_unparent(Object *obj)
{
DeviceState *dev = DEVICE(obj);
- bus_remove_child(dev->parent_bus, dev);
+ if (dev->parent_bus != NULL) {
+ bus_remove_child(dev->parent_bus, dev);
+ }
}
static void device_class_init(ObjectClass *class, void *data)
{
- class->unparent = qdev_remove_from_bus;
+ class->unparent = device_unparent;
}
void device_reset(DeviceState *dev)