]> git.ipfire.org Git - thirdparty/qemu.git/commit
qom: fix refcount of non-heap-allocated objects
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 23 Nov 2012 08:47:12 +0000 (09:47 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 3 Dec 2012 21:02:28 +0000 (15:02 -0600)
commitf05a3da4e00d24c4540811e6fff2c4f0484771bd
treeeb9563ff1e5287a0b7e2fbe62542cd7ab7acbdb5
parent0aad8f1a49fe49b15858978a03b4adead669ff6d
qom: fix refcount of non-heap-allocated objects

The reference count for embedded objects is always one too low, because
object_initialize_with_type returns with zero references to the object.
This causes premature finalization of the object (or an assertion failure)
after calling object_ref to add an extra reference and object_unref to
remove it.

The fix is to move the initial object_ref call from object_new_with_type
to object_initialize_with_type.

Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 764b63125a77dab54ed405d493452a4e05679c2e)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qom/object.c