qom: Clearer reference counting in object_initialize_childv()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200505152926.18877-2-armbru@redhat.com>
This commit is contained in:
parent
013a18edbb
commit
975ac4559c
16
qom/object.c
16
qom/object.c
@ -571,18 +571,18 @@ void object_initialize_childv(Object *parentobj, const char *propname,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
/*
|
/*
|
||||||
* Since object_property_add_child added a reference to the child object,
|
* We want @obj's reference to be 1 on success, 0 on failure.
|
||||||
* we can drop the reference added by object_initialize(), so the child
|
* On success, it's 2: one taken by object_initialize(), and one
|
||||||
* property will own the only reference to the object.
|
* by object_property_add_child().
|
||||||
|
* On failure in object_initialize() or earlier, it's 1.
|
||||||
|
* On failure afterwards, it's also 1: object_unparent() releases
|
||||||
|
* the reference taken by object_property_add_child().
|
||||||
*/
|
*/
|
||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
|
|
||||||
out:
|
error_propagate(errp, local_err);
|
||||||
if (local_err) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
object_unref(obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool object_property_is_child(ObjectProperty *prop)
|
static inline bool object_property_is_child(ObjectProperty *prop)
|
||||||
|
Loading…
Reference in New Issue
Block a user