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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7494DC433EF for ; Tue, 30 Nov 2021 14:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DZNPw9YumUIoPsgYFV27vCNoT+ROD45bnf0Nsw25R/Q=; b=tm3047tEkHlpDmeUMv+8H5UtWM 3p7LN2RhkRxy32rsNvua5pmYU3blYDqOTnabAycLno3+3y4LVEDf3A+aQPIo7Kgu4hka1mLiugnyU S6VRMmTQK1zyALweDmeS7XlVsvrkAdDonRagoKr0GHzvftmKY275CN7wgLrv61f8uxS3dxNL94a3l 2bR88SNo9UeLotTCCl1PJlVxQDgGgVgSdbQ1gdqCjgNS9TwJ7qc6twYrfJnXgHYAwNa3tC5lus7Rg C/gilE8kqhzMJg0GRo0xdDyg/G3PUEnrP2VtmXoYGgIGvF6Tnc8bM9Fg3u9vjVA3b4R/o3OB00HiT dfHx1iiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ms4SM-005gqL-Pt; Tue, 30 Nov 2021 14:50:06 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ms4RG-005gBu-ID for linux-nvme@lists.infradead.org; Tue, 30 Nov 2021 14:49:00 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 38302B81A2A; Tue, 30 Nov 2021 14:48:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E942DC53FD2; Tue, 30 Nov 2021 14:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638283736; bh=GvhueYt+SCekSCF1JsdL8Kt4Hd/djiouHtIFM5n5YM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TsdoSiUPIjTRO60bsesEgd/Z35fcqTM/aNcBsY/EkqobA9EoIGG4mqMAVs11eXt6Z vDfi8gtOmPwrnrxLn0kVtxVmGaU2RpOBUv+Z08H69sr3WDMG/eR3/DDMh6iUEaCMsS 7URBJyTlQd+wmwmPvIo0uJ56/zI0cigdnBdK7tbXxtFLyEQG2sz6U9lcx7G6ex28QO fciv6qGh8BANmKpImCvIJN7PQyE+Vumw/QEwT+8tVvyriSN7exmbYTCneLFv8ar/Ne Li+svO4oa+oR76wEmqIMAiJJC9mbCFYh2vkKC16nlr/u+rz9upO1OSd78W7u0QS0FZ gBYmU8Zq9VIYw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maurizio Lombardi , Keith Busch , Sagi Grimberg , John Meneghini , Christoph Hellwig , Sasha Levin , kch@nvidia.com, linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 5.15 42/68] nvmet-tcp: fix memory leak when performing a controller reset Date: Tue, 30 Nov 2021 09:46:38 -0500 Message-Id: <20211130144707.944580-42-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211130144707.944580-1-sashal@kernel.org> References: <20211130144707.944580-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211130_064858_790533_3A8C94A5 X-CRM114-Status: GOOD ( 15.46 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org From: Maurizio Lombardi [ Upstream commit af21250bb503a02e705b461886321e394b300524 ] If a reset controller is executed while the initiator is performing some I/O the driver may leak the memory allocated for the commands' iovec. Make sure that nvmet_tcp_uninit_data_in_cmds() releases all the memory. Signed-off-by: Maurizio Lombardi Reviewed-by: Keith Busch Reviewed-by: Sagi Grimberg Reviewed-by: John Meneghini Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/tcp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 786b1440a9af4..605aa2a8ca536 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1427,7 +1427,10 @@ static void nvmet_tcp_uninit_data_in_cmds(struct nvmet_tcp_queue *queue) for (i = 0; i < queue->nr_cmds; i++, cmd++) { if (nvmet_tcp_need_data_in(cmd)) - nvmet_tcp_finish_cmd(cmd); + nvmet_req_uninit(&cmd->req); + + nvmet_tcp_unmap_pdu_iovec(cmd); + nvmet_tcp_free_cmd_buffers(cmd); } if (!queue->nr_cmds && nvmet_tcp_need_data_in(&queue->connect)) { -- 2.33.0