From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB53CA9EB9 for ; Sat, 26 Oct 2019 13:18:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F1DE4222C9 for ; Sat, 26 Oct 2019 13:18:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MLHPyllP"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="CWHdc92A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1DE4222C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i88daujK0UlTu0cyyQ6QGDk+K9QPsAe/FseyghG3uCY=; b=MLHPyllPzqbX5c MSbWtaGSJ3UN9fd1kz8/5/RypalIp3aFQ/3T4JOZPyPAfjd0XAebIkmAvfbAKHKHedk3Il/gK59HI 8BuVqw0ApHD1NfzmrRi6uzpBwJYdUTfrmZwpSvdTURNyQ+WIhz7eBNhWBTpcMDkdbnJgLhB5VIZTZ mqw17iXNDLtKgFVQawZ3rTHXZRKP/iOim5flByqrjJrooi+QZtOUtrOGS0nD0OnPSDxvxO3727oiI XpOj/1zLXm72SaS45BypIlh65sVGa4rSYQQ0Mars/DjgInYMnwYqCQLnmO7Eupbql9uLykKnbdQjc UncQavWn7oJk6Ry4sRBA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iOLxd-0007jT-KI; Sat, 26 Oct 2019 13:18:29 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iOLxN-0007VG-5M for linux-nvme@lists.infradead.org; Sat, 26 Oct 2019 13:18:16 +0000 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B64721D81; Sat, 26 Oct 2019 13:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572095892; bh=CVo0oWZV+4414TStO0duI+OdPoiIoY8ztX3k3RdMuxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CWHdc92A9mZKGAnNtBVkNROoSZBfce56rKB9GABzXK90bH3XaHrOVL9R/nl5TUV4S tUNMAgiZ3dJ3hvZDpSPbxZOFz7U71XJJzXko61GgDRbuL7dC6jr/sVJZuJcyUyYhLe iH7FSUNMiIHbDonE+6b5C3uC+8WQGERsfcDuEUSY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.3 74/99] nvmet-loop: fix possible leakage during error flow Date: Sat, 26 Oct 2019 09:15:35 -0400 Message-Id: <20191026131600.2507-74-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191026131600.2507-1-sashal@kernel.org> References: <20191026131600.2507-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191026_061813_321879_E2421311 X-CRM114-Status: GOOD ( 10.15 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Max Gurtovoy , Christoph Hellwig , linux-nvme@lists.infradead.org, Sasha Levin Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org From: Max Gurtovoy [ Upstream commit 5812d04c4c7455627d8722e04ab99a737cfe9713 ] During nvme_loop_queue_rq error flow, one must call nvme_cleanup_cmd since it's symmetric to nvme_setup_cmd. Signed-off-by: Max Gurtovoy Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/loop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index 0940c5024a345..7b857c3f67879 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -157,8 +157,10 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx, iod->sg_table.sgl = iod->first_sgl; if (sg_alloc_table_chained(&iod->sg_table, blk_rq_nr_phys_segments(req), - iod->sg_table.sgl, SG_CHUNK_SIZE)) + iod->sg_table.sgl, SG_CHUNK_SIZE)) { + nvme_cleanup_cmd(req); return BLK_STS_RESOURCE; + } iod->req.sg = iod->sg_table.sgl; iod->req.sg_cnt = blk_rq_map_sg(req->q, req, iod->sg_table.sgl); -- 2.20.1 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme