From patchwork Tue Oct 18 09:17:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pino Toscano X-Patchwork-Id: 9381667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9016C60839 for ; Tue, 18 Oct 2016 09:18:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8020129469 for ; Tue, 18 Oct 2016 09:18:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B7262947E; Tue, 18 Oct 2016 09:18:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1ADBD29469 for ; Tue, 18 Oct 2016 09:18:19 +0000 (UTC) Received: from localhost ([::1]:39789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwQXJ-0002TG-Nq for patchwork-qemu-devel@patchwork.kernel.org; Tue, 18 Oct 2016 05:18:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwQWz-0002Sx-ND for qemu-devel@nongnu.org; Tue, 18 Oct 2016 05:17:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwQWw-0006ED-Js for qemu-devel@nongnu.org; Tue, 18 Oct 2016 05:17:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53086) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwQWw-0006Dm-Em for qemu-devel@nongnu.org; Tue, 18 Oct 2016 05:17:54 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1861781239; Tue, 18 Oct 2016 09:17:53 +0000 (UTC) Received: from thyrus.usersys.redhat.com (dhcp131-138.brq.redhat.com [10.34.131.138]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9I9Hob1003657 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 18 Oct 2016 05:17:51 -0400 From: Pino Toscano To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2016 11:17:47 +0200 Message-Id: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 18 Oct 2016 09:17:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qapi: fix memory leak in QmpOutputVisitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ptoscano@redhat.com, armbru@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. Reviewed-by: Eric Blake --- 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); }