From patchwork Wed Oct 12 13:10:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9372953 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 08AF560839 for ; Wed, 12 Oct 2016 13:19:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE3FF29DAD for ; Wed, 12 Oct 2016 13:19:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2C9B29DB9; Wed, 12 Oct 2016 13:19:45 +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 BC90229DAD for ; Wed, 12 Oct 2016 13:19:44 +0000 (UTC) Received: from localhost ([::1]:33540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buJRf-0003ac-Um for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Oct 2016 09:19:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buJJN-0005RK-0Y for qemu-devel@nongnu.org; Wed, 12 Oct 2016 09:11:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buJJH-0004H3-PT for qemu-devel@nongnu.org; Wed, 12 Oct 2016 09:11:07 -0400 Received: from mail-io0-x244.google.com ([2607:f8b0:4001:c06::244]:36236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buJJH-0004Gu-L9 for qemu-devel@nongnu.org; Wed, 12 Oct 2016 09:11:03 -0400 Received: by mail-io0-x244.google.com with SMTP id o141so3010968ioe.3 for ; Wed, 12 Oct 2016 06:11: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=Xe6rsLpRv0+2Dmf2MydQ7/qp9UO1xzUjfmCT+trzaaA=; b=lOfl9teuu/H2Qwnf7ekpOpl+tnmpymRyDq8MOJkVtFXfUFtqUp+pkbUW9yUts+NZOx u8cOTk3CzAqzMkOkL3CZpY0FVswB5n7GaUtkaWJBaW4ovl1KRJrcQsaPWvNREc7G6fvy 4rIM7ciMrykSLblwncFGmv/6fLzh4p7/yZVOZ5b/FDcj3YSSzJ9QZwsCjg/ZVpfhOOMF jBJ5OIo4ekAJEim5LdJ/GeKe7pNszlOcvnqdaaZC1GwHgLbx8SbvZ6DDO2ZLMKF5ooCo nfLSUVyEMnghGvJ+Riwl/VuwmcBnwfInMnArkDzY3LPVatmRCgnl/C4XHfVwWK/dt19+ 0AQA== 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=Xe6rsLpRv0+2Dmf2MydQ7/qp9UO1xzUjfmCT+trzaaA=; b=dVMEjk+UokpuJ5NiXJQtiqQ1Y9ZBrcch4vTlI2qySYc1jnP8kDxvmN9apmmubkX02J IyCt1R+degOdtHb8SeNurdAbvBU6BnZyYqGMJQ2KVz0sh2vE7FxHCORUVXh23zh/JScf CNflQcbUs2l9dat2j6/IBak3MERuDTHl6GW7ZDOX+valtx37b1U8KFroqqZrr0WBNzIO PcJeEe91+z2ZfVh1z0C7WyAVH6GKPNi2h8mXY5qYMRUlvQOe7ML6TWU4otevJlybZHv4 J8mUTuMK9D8pjguksnhuSLDvSeXDqa+R7faMLf8RPUBfk5R1U47qitGJxxqPQRPBUwbm Sw7Q== X-Gm-Message-State: AA6/9RnpAyLdgnZ03CY4oKbUXNOzMTTAEF21DqIHJ+iqQFwBqaxuk1QVIsKKQRmXkR/tvQ== X-Received: by 10.107.139.79 with SMTP id n76mr1529676iod.166.1476277863065; Wed, 12 Oct 2016 06:11:03 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id g1sm5340483ite.12.2016.10.12.06.11.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Oct 2016 06:11:02 -0700 (PDT) Message-ID: <57fe3666.018b240a.e96e4.4825@mx.google.com> X-Google-Original-Message-ID: <1476277856-8416-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: groug@kaod.org, qemu-devel@nongnu.org Date: Wed, 12 Oct 2016 06:10:56 -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:c06::244 Subject: [Qemu-devel] [PATCH v2] 9pfs: fix memory leak in v9fs_write 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 If an error occurs when marshal the transfer length to the guest, the v9fs_write doesn't free an IO vector, thus leading a memory leak. This patch fix this. Signed-off-by: Li Qiang Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 8b50bfb..c8cf8c2 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2090,7 +2090,7 @@ static void v9fs_write(void *opaque) offset = 7; err = pdu_marshal(pdu, offset, "d", total); if (err < 0) { - goto out; + goto out_qiov; } err += offset; trace_v9fs_write_return(pdu->tag, pdu->id, total, err);