]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
qdev: add reference for the bus while it is referred to by the DeviceState
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Jan 2013 13:12:35 +0000 (14:12 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 1 Feb 2013 21:53:10 +0000 (15:53 -0600)
Now that the unparent callbacks are complete, we can correctly account
more missing references.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/qdev.c

index 6f1b3117fff04bf43b6ba56dda5e811a5238196f..1dabcad2a624b40eeb0e99c33d34f930b83928b2 100644 (file)
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -100,6 +100,7 @@ static void bus_add_child(BusState *bus, DeviceState *child)
 void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
 {
     dev->parent_bus = bus;
+    object_ref(OBJECT(bus));
     bus_add_child(bus, dev);
 }
 
@@ -773,6 +774,8 @@ static void device_unparent(Object *obj)
     }
     if (dev->parent_bus) {
         bus_remove_child(dev->parent_bus, dev);
+        object_unref(OBJECT(dev->parent_bus));
+        dev->parent_bus = NULL;
     }
 }