From patchwork Tue Sep 27 04:42:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9351483 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 AEA7D6077A for ; Tue, 27 Sep 2016 04:43:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 968FE28F3F for ; Tue, 27 Sep 2016 04:43:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8903B28F4B; Tue, 27 Sep 2016 04:43:27 +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 F213828F3F for ; Tue, 27 Sep 2016 04:43:26 +0000 (UTC) Received: from localhost ([::1]:47982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bokEo-0003LX-7R for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Sep 2016 00:43:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bokEZ-0003LS-KB for qemu-devel@nongnu.org; Tue, 27 Sep 2016 00:43:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bokET-0007MB-MJ for qemu-devel@nongnu.org; Tue, 27 Sep 2016 00:43:10 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:36256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bokET-0007Lz-G3 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 00:43:05 -0400 Received: by mail-oi0-x244.google.com with SMTP id i193so167194oib.3 for ; Mon, 26 Sep 2016 21:43:05 -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=n9Q6aT74t7PYDteMEMt95rhUtfbGTVEPXJCcnOZyQEg=; b=DbB58302Mbv9cjFuvNbQWGpXs/u5T9iFVZIXFKh2DQwFOAjvfCLaRzXJmzeQyGNm0z Ss3kIWwRi6DsP8PzNvMMXzqZ5r+G7wqCYF+aTelvL5lA7RuwRAxkkDapXeK3nDR8fcnK UK6Lq5n2jW71E6IlOoh2Vpf1L5ZMnV1LOiB013+B/nd0t5koFrA+OlkPqxc6iJd8QEr/ dS9sBWbhBtx7/7EQb9rbzTgZg4DHeKByC62o/1JbLVNog8JZKiuDOUfogya4Ky9/ErFz qIOsIkr6NQaeYhTpyAt88EKeDYuibGOLLrH+E0HTz9+FPlpr2jOzTlSVJChoREAHKs7B PngA== 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=n9Q6aT74t7PYDteMEMt95rhUtfbGTVEPXJCcnOZyQEg=; b=MjcvzmSGS9tSn2tmfGWEQ9nfGqAVEcSVtbdPU1/lzut2jUayfT7e/hj+iBoTib7LUA MUPI07S3niIQ1nWSTk/TXUW8N2ynBdQNle1BXFYdzazZN5d260xbrR7OXvW8g0k1HCRD RPc3tx1auTDh+QCb/if7ZpeYODgAsC3gJbTroR6D03lQNU4tqJYCMbw4AO/9fmrM2j35 Rh3lt2Anf8J3TqIgUR7E72ZH+p4DIefmjzMfjwo9C/Osx4scy40UJ4cVaaCa78bc908m 055TfBicYMe5B101B+HIyuQz5MTZYizbnPAtG5gAN4NweSTeI5iedylqmUd2SOYLWT60 1Xfg== X-Gm-Message-State: AE9vXwN2EVBR8Zxej1VNm6SSVfbDPu7m8q+QnwfbzFFG3J/Ch2Ncz+9e3l/AUQfGa4GPcg== X-Received: by 10.202.89.66 with SMTP id n63mr33433631oib.90.1474951384779; Mon, 26 Sep 2016 21:43:04 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id 37sm180529otd.7.2016.09.26.21.43.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Sep 2016 21:43:04 -0700 (PDT) Message-ID: <57e9f8d8.a8059d0a.58e91.0d98@mx.google.com> X-Google-Original-Message-ID: <1474951346-16117-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: Mon, 26 Sep 2016 21:42:26 -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:4003:c06::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 --- hw/9pfs/9p.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index d960a2e..b1ff8e7 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1830,12 +1830,16 @@ static void v9fs_read(void *opaque) } while (len == -EINTR && !pdu->cancelled); if (len < 0) { /* IO error return the error */ + qemu_iovec_destroy(&qiov); + qemu_iovec_destroy(&qiov_full); err = len; goto out; } } while (count < max_count && len > 0); err = pdu_marshal(pdu, offset, "d", count); if (err < 0) { + qemu_iovec_destroy(&qiov); + qemu_iovec_destroy(&qiov_full); goto out; } err += offset + count;