[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qom: In function object_set_link_property(), fi
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref(). |
Date: |
Wed, 22 Feb 2012 18:24:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120209 Thunderbird/10.0.1 |
On 02/22/2012 06:22 PM, address@hidden wrote:
> From: Alexander Barabash <address@hidden>
>
> In the old implementation, if the new value of the property links
> to the same object, as the old value, that object is first unref-ed,
> and then ref-ed. This leads to unintended deinitialization of that object.
>
> In the new implementation, this is fixed.
>
> Signed-off-by: Alexander Barabash <address@hidden>
> ---
> qom/object.c | 11 +++++++----
> 1 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 941c291..e6591e1 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -892,6 +892,7 @@ static void object_set_link_property(Object *obj, Visitor
> *v, void *opaque,
> const char *name, Error **errp)
> {
> Object **child = opaque;
> + Object *old_target;
> bool ambiguous = false;
> const char *type;
> char *path;
> @@ -901,10 +902,8 @@ static void object_set_link_property(Object *obj,
> Visitor *v, void *opaque,
>
> visit_type_str(v, &path, name, errp);
>
> - if (*child) {
> - object_unref(*child);
> - *child = NULL;
> - }
> + old_target = *child;
> + *child = NULL;
>
> if (strcmp(path, "") != 0) {
> Object *target;
> @@ -930,6 +929,10 @@ static void object_set_link_property(Object *obj,
> Visitor *v, void *opaque,
> }
>
> g_free(path);
> +
> + if (old_target != NULL) {
> + object_unref(old_target);
> + }
> }
>
> void object_property_add_link(Object *obj, const char *name,
Reviewed-by: Paolo Bonzini <address@hidden>
- [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref()., alexander_barabash, 2012/02/22
- [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref()., alexander_barabash, 2012/02/22
- Re: [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref().,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref()., Anthony Liguori, 2012/02/24