mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-04 07:33:41 -10:00
virtio-rng: fix virtio-rng child refcount in transports
object_initialize() leaves the object with a refcount of 1.
object_property_add_child() adds its own reference which is dropped
again when the property is deleted.
The upshot of this is that we always have a refcount >= 1. Upon hot
unplug the virtio-rng child is not finalized!
Drop our reference after the child property has been added to the
parent.
Signed-off-by: Gonglei <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
(cherry picked from commit 352fa88dfb)
Signed-off-by: Michael Roth <[email protected]>
This commit is contained in:
1 parent
c4164eae39
commit
0077793a00
3 files changed
+3
No files matched your search
@@ -312,6 +312,7 @@ static void s390_virtio_rng_instance_init(Object *obj)
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
||||
(Object **)&dev->vdev.conf.rng,
|
||||
qdev_prop_allow_set_link_before_realize,
|
||||
|
||||
@@ -1543,6 +1543,7 @@ static void virtio_ccw_rng_instance_init(Object *obj)
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
||||
(Object **)&dev->vdev.conf.rng,
|
||||
qdev_prop_allow_set_link_before_realize,
|
||||
|
||||
@@ -1527,6 +1527,7 @@ static void virtio_rng_initfn(Object *obj)
|
||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
|
||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||
object_unref(OBJECT(&dev->vdev));
|
||||
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
||||
(Object **)&dev->vdev.conf.rng,
|
||||
qdev_prop_allow_set_link_before_realize,
|
||||
|
||||
Reference in new issue
Block a user