From patchwork Tue Sep 27 11:58:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9351785 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 9015E6077A for ; Tue, 27 Sep 2016 12:08:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 814EB291CD for ; Tue, 27 Sep 2016 12:08:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75EAA291D1; Tue, 27 Sep 2016 12:08:14 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 93580291CD for ; Tue, 27 Sep 2016 12:08:13 +0000 (UTC) Received: from localhost ([::1]:50182 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1borBE-000502-Ln for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Sep 2016 08:08:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bor2R-0003Hn-GZ for qemu-devel@nongnu.org; Tue, 27 Sep 2016 07:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bor2N-00018Z-J0 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 07:59:07 -0400 Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]:34214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bor2N-00018M-BG for qemu-devel@nongnu.org; Tue, 27 Sep 2016 07:59:03 -0400 Received: by mail-it0-x244.google.com with SMTP id j69so769342itb.1 for ; Tue, 27 Sep 2016 04:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=jp6N9p0CG01USXPYo2gTflyUQSDtgKJF6iZpp3sPuW8=; b=KbkaLZHsn1Ms/uYFp6rxXmclr0sLyW02y1OELPvQBzfeqqpIWLQLntqvh2bTftnuO4 UZjv0CP/zglqWr2J/V3e1TUEoLiVfFGbmi+iZb33HN+4oGWalTbCsTsEfPyYPNxOzNwd Kngg1Ct/dEHSonU2UH+Z5HS9I5DZfQDrBQPD1GZsOfqs4CKto5h7hl95Z2JJKuWQuYik xMlEQYuapTijX8s9o6KFP07ieOax27ozqOfFPSRZNo/JvvwjeR4+9g/rDWbk5F3RXw/d IMdLDgGZ5mWTJoY/kQr7SZRpTwcfooKLoqJz+CQJDMz7SnYOL5wt4YxqttwZMSMx2PVf qkYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=jp6N9p0CG01USXPYo2gTflyUQSDtgKJF6iZpp3sPuW8=; b=GpydnIshLYqGLF8/YASe5frI/7aXEWHKLGYBDjZ84AhOa/YGpeJDCPOR3UNcUNXGis laBEDRghvQQsm2Nf4ibrfSLKx3XZbUOXcsGcDTfokaZDmfDo46wjxHqYZ5JiaBHI/SIV Mg0SSzICs9xzXN/TpDQifcqul4eFIB2dsacWxr17lsu5rmEqvrEzq3tmRP1iEgrHRNi3 0waNtvgRg+9PuXBL/qlJ9XKXNOTlnuqrjyCHd0/pZeeyjJy+EQrnA0Hxbg87Y8Stwq++ wCkqI6FCS7A8IHatw1ABCwHJlpklGLE7LYvIFw+kL4+rzr2U7gdRFUOfZe2/I8UJ2mjk /Jkw== X-Gm-Message-State: AA6/9RlSrXHgJCVSm5C66EWeLuTHROvwt27xH/LBeAs0wp4XECQ4MwZKvoT1LoKLZ0zDFw== X-Received: by 10.36.14.68 with SMTP id 65mr3286045ite.99.1474977542642; Tue, 27 Sep 2016 04:59:02 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id e124sm851305ioe.15.2016.09.27.04.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 04:59:02 -0700 (PDT) Message-ID: <57ea5f06.821e6b0a.4ee38.31ea@mx.google.com> X-Google-Original-Message-ID: <1474977526-7517-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: aneesh.kumar@linux.vnet.ibm.com, groug@kaod.org, qemu-devel@nongnu.org Date: Tue, 27 Sep 2016 04:58:46 -0700 X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c0b::244 Subject: [Qemu-devel] [PATCH] 9pfs: fix potential host memory leak in v9fs_read 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: Li Qiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Li Qiang In 9pfs read dispatch function, it doesn't free two QEMUIOVector object thus causing potential memory leak. This patch avoid this. Signed-off-by: Li Qiang Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 119ee58..543a791 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1826,14 +1826,15 @@ static void v9fs_read(void *opaque) if (len < 0) { /* IO error return the error */ err = len; - goto out; + goto out_free_iovec; } } while (count < max_count && len > 0); err = pdu_marshal(pdu, offset, "d", count); if (err < 0) { - goto out; + goto out_free_iovec; } err += offset + count; +out_free_iovec: qemu_iovec_destroy(&qiov); qemu_iovec_destroy(&qiov_full); } else if (fidp->fid_type == P9_FID_XATTR) {