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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF2E9C433EF for ; Tue, 30 Nov 2021 14:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243603AbhK3O5h (ORCPT ); Tue, 30 Nov 2021 09:57:37 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:58866 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242943AbhK3Oyw (ORCPT ); Tue, 30 Nov 2021 09:54:52 -0500 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 sin.source.kernel.org (Postfix) with ESMTPS id 211C7CE1A5E; Tue, 30 Nov 2021 14:51:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BE81C58327; Tue, 30 Nov 2021 14:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638283890; bh=pYSqKmHSJFO+ETC9QgsF3/poW7ilfYOo08geY76RAG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j0Ubi9Zd0nfB3xitNa/+zs9IvLMDxzfheW6U/MYCy66tjKTqOhGBidip7rlIvjwzZ /hMog1iBYYfDP4GwXZo4oxWet2uwkW1+Z1hvUCxMjPl0LrtSe8DkHz/fHC2JUtXLrg USCu5Io/WsjC8HBy/CUXE1lFqE6eAJx/Mbc9csNS4qh/QxkEq4bI+8JwzR9ZlCspnU kLKt432mYqKpnLQxtrccR73ZDd6R9htWUIkwlUiDEL4bva6SxbO4Q8DTQfGvogF8jx 3dA1ftB5jXK46LD7wzu+w5g2A0wD9nrdgeK0x4invhCyLn6L5eJfnfwW8M9O/O0ScQ AsXB1ZjP9bzmg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maurizio Lombardi , Sagi Grimberg , John Meneghini , Christoph Hellwig , Sasha Levin , kbusch@kernel.org, axboe@fb.com, linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 31/43] nvme-tcp: fix memory leak when freeing a queue Date: Tue, 30 Nov 2021 09:50:08 -0500 Message-Id: <20211130145022.945517-31-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211130145022.945517-1-sashal@kernel.org> References: <20211130145022.945517-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maurizio Lombardi [ Upstream commit a5053c92b3db71c3f7f9f13934ca620632828d06 ] Release the page frag cache when tearing down the io queues Signed-off-by: Maurizio Lombardi Reviewed-by: Sagi Grimberg Reviewed-by: John Meneghini Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/tcp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index c8efa98192a4f..aaad985175d60 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1212,6 +1212,7 @@ static int nvme_tcp_alloc_async_req(struct nvme_tcp_ctrl *ctrl) static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid) { + struct page *page; struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl); struct nvme_tcp_queue *queue = &ctrl->queues[qid]; @@ -1221,6 +1222,11 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid) if (queue->hdr_digest || queue->data_digest) nvme_tcp_free_crypto(queue); + if (queue->pf_cache.va) { + page = virt_to_head_page(queue->pf_cache.va); + __page_frag_cache_drain(page, queue->pf_cache.pagecnt_bias); + queue->pf_cache.va = NULL; + } sock_release(queue->sock); kfree(queue->pdu); mutex_destroy(&queue->queue_lock); -- 2.33.0