mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 03:13:44 +08:00
virtio-rng: Avoid default_backend refcount leak
QOM child properties take a reference to the object and release it when the property is deleted. Therefore we should unref the default_backend after we have added it as a child property. Cc: KONRAD Frederic <fred.konrad@greensocs.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
39f72ef94b
commit
abdffd1fb7
@ -162,6 +162,9 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
|
||||
OBJECT(vrng->conf.default_backend),
|
||||
NULL);
|
||||
|
||||
/* The child property took a reference, we can safely drop ours now */
|
||||
object_unref(OBJECT(vrng->conf.default_backend));
|
||||
|
||||
object_property_set_link(OBJECT(dev),
|
||||
OBJECT(vrng->conf.default_backend),
|
||||
"rng", NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user