From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4qWP-0001c7-RG for qemu-devel@nongnu.org; Fri, 24 Aug 2012 05:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4qWO-0002DT-P9 for qemu-devel@nongnu.org; Fri, 24 Aug 2012 05:49:45 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:39140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4qWO-0002Bz-LD for qemu-devel@nongnu.org; Fri, 24 Aug 2012 05:49:44 -0400 Received: by mail-iy0-f173.google.com with SMTP id x26so2918018iak.4 for ; Fri, 24 Aug 2012 02:49:44 -0700 (PDT) From: Liu Ping Fan Date: Fri, 24 Aug 2012 17:49:14 +0800 Message-Id: <1345801763-24227-2-git-send-email-qemulist@gmail.com> In-Reply-To: <1345801763-24227-1-git-send-email-qemulist@gmail.com> References: <1345801763-24227-1-git-send-email-qemulist@gmail.com> Subject: [Qemu-devel] [PATCH 01/10] qom: add, remove of link property need to ref, unref its target List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Liu Ping Fan , Avi Kivity , Anthony Liguori From: Liu Ping Fan Currently, link property's target is only managed by object_set_link_property(). This will raise such issue that when the property is finalized, its target has no opportunity to release. Fix this issue by introduce object_finalize_link_property() In correspond, ref target when adding link prpoerty. Signed-off-by: Liu Ping Fan --- qom/object.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index a552be2..00f98d7 100644 --- a/qom/object.c +++ b/qom/object.c @@ -957,6 +957,16 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, } } +static void object_finalize_link_property(Object *obj, const char *name, + void *opaque) +{ + Object **child = opaque; + + if (*child != NULL) { + object_unref(*child); + } +} + void object_property_add_link(Object *obj, const char *name, const char *type, Object **child, Error **errp) @@ -968,8 +978,10 @@ void object_property_add_link(Object *obj, const char *name, object_property_add(obj, name, full_type, object_get_link_property, object_set_link_property, - NULL, child, errp); - + object_finalize_link_property, child, errp); + if (*child != NULL) { + object_ref(*child); + } g_free(full_type); } -- 1.7.4.4