summary refs log tree commit diff stats
path: root/hw/core/qdev-properties.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2016-07-25 11:59:22 +0200
committerEduardo Habkost <ehabkost@redhat.com>2016-07-26 15:32:04 -0300
commit69382d8b3e8600b349c191394d761dcb480502cf (patch)
treed996c397ca0aede09fe68c8bbf7a4b26e28ed369 /hw/core/qdev-properties.c
parenta07f953ef4ef48058c24fb50b49e6fa28bf5f5f4 (diff)
downloadfocaccia-qemu-69382d8b3e8600b349c191394d761dcb480502cf.tar.gz
focaccia-qemu-69382d8b3e8600b349c191394d761dcb480502cf.zip
qdev: Fix object reference leak in case device.realize() fails
If device doesn't have parent assined before its realize
is called, device_set_realized() will implicitly set parent
to '/machine/unattached'.

However device_set_realized() may fail after that point at
several other points leaving not realized object dangling
in '/machine/unattached' and as result caller of

  obj = object_new()
    obj->ref == 1
  object_property_set_bool(obj,..., true, "realized",...)
    obj->ref == 2
  if (fail)
      object_unref(obj);
      obj->ref == 1

will get object leak instead of expected object destruction.

Fix it by making device_set_realized() to cleanup after itself
in case of failure.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/core/qdev-properties.c')
0 files changed, 0 insertions, 0 deletions