Received: from eggs.gnu.org ([2001:4830:134:3::10]:56812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxaOV-0002LJ-8N for qemu-devel@nongnu.org; Fri, 21 Oct 2016 10:02:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxaOR-0004Wu-Hk for qemu-devel@nongnu.org; Fri, 21 Oct 2016 10:01:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxaOR-0004VI-DU for qemu-devel@nongnu.org; Fri, 21 Oct 2016 10:01:55 -0400 From: Markus Armbruster References: <1476787052-27333-1-git-send-email-ptoscano@redhat.com> Date: Fri, 21 Oct 2016 16:01:52 +0200 In-Reply-To: <1476787052-27333-1-git-send-email-ptoscano@redhat.com> (Pino Toscano's message of "Tue, 18 Oct 2016 12:37:32 +0200") Message-ID: <877f91ztpr.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2] qapi: fix memory leak in QmpOutputVisitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pino Toscano Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Pino Toscano writes: > qmp_output_start_struct() and qmp_output_start_list() create a new > QObject (QDict, QList) and push it to the stack of the QmpOutputVisitor, > where it is saved as 'value'. When freeing the iterator in > qmp_output_free(), these values are never freed properly. > > The simple solution is to qobject_decref() them. > > Signed-off-by: Pino Toscano > --- > > Changes in v2: > - added Signed-off-by > > qapi/qmp-output-visitor.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c > index 9e3b67c..eedf256 100644 > --- a/qapi/qmp-output-visitor.c > +++ b/qapi/qmp-output-visitor.c > @@ -220,6 +220,7 @@ static void qmp_output_free(Visitor *v) > while (!QSLIST_EMPTY(&qov->stack)) { > e = QSLIST_FIRST(&qov->stack); > QSLIST_REMOVE_HEAD(&qov->stack, node); > + qobject_decref(e->value); > g_free(e); > } Hmm. The patch looks correct, even though it adds a decref very similar to the one deleted by commit f24582d "qapi: fix double free in qmp_output_visitor_cleanup()". I suspect the bug you fix was introduced by commit 455ba08 "qmp: Don't abuse stack to track qmp-output root". Eric? Should this go into -stable?