From: Alexander Barabash <alexander_barabash@mentor.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref().
Date: Wed, 22 Feb 2012 19:25:37 +0200 [thread overview]
Message-ID: <4F452511.40501@mentor.com> (raw)
In-Reply-To: <4F4524B3.7020500@redhat.com>
On 02/22/2012 07:24 PM, Paolo Bonzini wrote:
> On 02/22/2012 06:22 PM, alexander_barabash@mentor.com wrote:
>> From: Alexander Barabash<alexander_barabash@mentor.com>
>>
>> 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<alexander_barabash@mentor.com>
>> ---
>> 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<pbonzini@redhat.com>
Sorry, I did not figure out yet how to add the "v2" to the subject line. ))
Alex
next prev parent reply other threads:[~2012-02-22 17:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-22 17:22 [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref() alexander_barabash
2012-02-22 17:24 ` Paolo Bonzini
2012-02-22 17:25 ` Alexander Barabash [this message]
2012-02-22 17:52 ` Eric Blake
2012-02-24 15:32 ` Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2012-02-22 17:13 alexander_barabash
2012-02-22 17:17 ` Paolo Bonzini
2012-02-22 17:19 ` Alexander Barabash
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F452511.40501@mentor.com \
--to=alexander_barabash@mentor.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.