From patchwork Fri Aug 1 10:22:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenfan X-Patchwork-Id: 375700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 102AA140110 for ; Fri, 1 Aug 2014 20:29:01 +1000 (EST) Received: from localhost ([::1]:38348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDA55-0001k8-5e for incoming@patchwork.ozlabs.org; Fri, 01 Aug 2014 06:28:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDA3R-0007iQ-E8 for qemu-devel@nongnu.org; Fri, 01 Aug 2014 06:27:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XDA3H-0003nz-UJ for qemu-devel@nongnu.org; Fri, 01 Aug 2014 06:27:17 -0400 Received: from [59.151.112.132] (port=46461 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDA3H-0003mQ-Hl for qemu-devel@nongnu.org; Fri, 01 Aug 2014 06:27:07 -0400 X-IronPort-AV: E=Sophos;i="5.04,243,1406563200"; d="scan'208";a="34068086" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 01 Aug 2014 18:24:17 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s71AR2jJ028826 for ; Fri, 1 Aug 2014 18:27:02 +0800 Received: from G08FNSTD131468.fnst.cn.fujitsu.com (10.167.226.78) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 1 Aug 2014 18:27:05 +0800 From: Chen Fan To: Date: Fri, 1 Aug 2014 18:22:42 +0800 Message-ID: <1406888562-15114-4-git-send-email-chen.fan.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406888562-15114-1-git-send-email-chen.fan.fnst@cn.fujitsu.com> References: <1406888562-15114-1-git-send-email-chen.fan.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.78] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 3/3] hmp: fix MemdevList memory leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Chen Fan --- hmp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hmp.c b/hmp.c index 2414cc7..0b1c830 100644 --- a/hmp.c +++ b/hmp.c @@ -1685,13 +1685,14 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) { Error *err = NULL; MemdevList *memdev_list = qmp_query_memdev(&err); - MemdevList *m = memdev_list; + MemdevList *m; StringOutputVisitor *ov; char *str; int i = 0; - while (m) { + while (memdev_list) { + m = memdev_list; ov = string_output_visitor_new(false); visit_type_uint16List(string_output_get_visitor(ov), &m->value->host_nodes, NULL, NULL); @@ -1710,7 +1711,9 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) string_output_visitor_cleanup(ov); g_free(str); - m = m->next; + memdev_list = memdev_list->next; + g_free(m->value); + g_free(m); i++; }