From patchwork Mon Oct 10 09:46:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 9369283 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 D740960487 for ; Mon, 10 Oct 2016 10:01:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7E1128D6C for ; Mon, 10 Oct 2016 10:01:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC73128E92; Mon, 10 Oct 2016 10:01:59 +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 3E04028D6C for ; Mon, 10 Oct 2016 10:01:59 +0000 (UTC) Received: from localhost ([::1]:48554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btXPB-0008Ri-VS for patchwork-qemu-devel@patchwork.kernel.org; Mon, 10 Oct 2016 06:01:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btXAA-0004Zt-5A for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:46:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btXA6-0008Ey-T9 for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:46:26 -0400 Received: from [59.151.112.132] (port=37208 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btXA6-0008CO-Gp for qemu-devel@nongnu.org; Mon, 10 Oct 2016 05:46:22 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="11783744" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Oct 2016 17:46:15 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 6FB2C41B5F47; Mon, 10 Oct 2016 17:46:13 +0800 (CST) Received: from localhost.localdomain (10.167.226.56) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Mon, 10 Oct 2016 17:46:16 +0800 From: Zhang Chen To: qemu devel , Jason Wang , Zhang Chen , Li Zhijian , Paolo Bonzini Date: Mon, 10 Oct 2016 17:46:54 +0800 Message-ID: <1476092814-5199-1-git-send-email-zhangchen.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.56] X-yoursite-MailScanner-ID: 6FB2C41B5F47.ADD94 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: zhangchen.fnst@cn.fujitsu.com 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] colo-proxy: fix memory leak 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fix memory leak in colo-compare.c and filter-rewriter.c Report by Coverity. Signed-off-by: Zhang Chen --- net/colo-compare.c | 4 ++-- net/filter-rewriter.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 22b1da1..47e7ebe 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -235,8 +235,8 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) fprintf(stderr, "Secondary len = %d\n", spkt->size); qemu_hexdump((char *)spkt->data, stderr, "colo-compare", spkt->size); - g_free(sdebug); - g_free(ddebug); + free(sdebug); + free(ddebug); } return res; diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index 89abe72..396a03c 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -75,8 +75,8 @@ static int handle_primary_tcp_pkt(NetFilterState *nf, ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), tcp_pkt->th_flags); trace_colo_filter_rewriter_conn_offset(conn->offset); - g_free(sdebug); - g_free(ddebug); + free(sdebug); + free(ddebug); } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) { @@ -123,8 +123,8 @@ static int handle_secondary_tcp_pkt(NetFilterState *nf, ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), tcp_pkt->th_flags); trace_colo_filter_rewriter_conn_offset(conn->offset); - g_free(sdebug); - g_free(ddebug); + free(sdebug); + free(ddebug); } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == (TH_ACK | TH_SYN))) { @@ -162,6 +162,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf, iov_to_buf(iov, iovcnt, 0, buf, size); pkt = packet_new(buf, size); + g_free(buf); /* * if we get tcp packet