From: Paolo Bonzini Date: Fri, 25 Jan 2013 13:12:35 +0000 (+0100) Subject: qdev: add reference for the bus while it is referred to by the DeviceState X-Git-Tag: v1.4.0-rc0~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62d7ba669dbd5b4c92664eea453d28448ab9cb4b;p=thirdparty%2Fqemu.git qdev: add reference for the bus while it is referred to by the DeviceState Now that the unparent callbacks are complete, we can correctly account more missing references. Signed-off-by: Paolo Bonzini Signed-off-by: Anthony Liguori --- diff --git a/hw/qdev.c b/hw/qdev.c index 6f1b3117fff..1dabcad2a62 100644 --- 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; } }