From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0x8g-0001Y6-6f for qemu-devel@nongnu.org; Fri, 24 Feb 2012 10:32:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0x8e-0004hb-8T for qemu-devel@nongnu.org; Fri, 24 Feb 2012 10:32:53 -0500 Received: from e3.ny.us.ibm.com ([32.97.182.143]:38059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0x8e-0004hP-4U for qemu-devel@nongnu.org; Fri, 24 Feb 2012 10:32:52 -0500 Received: from /spool/local by e3.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 24 Feb 2012 10:32:46 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 4CC9138C806B for ; Fri, 24 Feb 2012 10:32:16 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q1OFWA1h236592 for ; Fri, 24 Feb 2012 10:32:10 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q1OFW6Hi005855 for ; Fri, 24 Feb 2012 13:32:06 -0200 Message-ID: <4F47AD74.6040300@us.ibm.com> Date: Fri, 24 Feb 2012 09:32:04 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1329931346-28207-1-git-send-email-alexander_barabash@mentor.com> In-Reply-To: <1329931346-28207-1-git-send-email-alexander_barabash@mentor.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qom: In function object_set_link_property(), first call object_ref(), then object_unref(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: alexander_barabash@mentor.com Cc: pbonzini@redhat.com, qemu-devel@nongnu.org On 02/22/2012 11:22 AM, alexander_barabash@mentor.com wrote: > From: Alexander Barabash > > 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 Applied. Thanks. Regards, Anthony Liguori > --- > 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,