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 AC25AC43219 for ; Tue, 30 Nov 2021 14:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242610AbhK3Ozh (ORCPT ); Tue, 30 Nov 2021 09:55:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242931AbhK3Ox2 (ORCPT ); Tue, 30 Nov 2021 09:53:28 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 193AEC0613A5; Tue, 30 Nov 2021 06:49:02 -0800 (PST) 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 92088CE1A44; Tue, 30 Nov 2021 14:49:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE51BC53FD0; Tue, 30 Nov 2021 14:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638283739; bh=OzFtNvqM7ulxBRhMNN5S2bm1o0/gjzkmnQfVJZNx4Fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uev7Bx9GdVa1m0NhONp/6DMH21oS5ws1JTo5a79LlF0ZtFJ2ezK/pI54xKIm3wW/P SDvAzNF3mmuKm8q4y7aozNiFzxKtDhfZUn58lsjfs+cEwEYTN3PqS9fFvDfOLXl0KK 3oaKLbEDc0OS/uR3WpKvWBnrb/oMfye+fbPcHH9UIK56AwfJiG+hWybuT92waVusMU aM9tedKRCDfzAlyFWtedloQo6PkHRwIVHR+YPG6iodtLcz/7ePgM40vrh0HB6bZRFf YrkRgZEX1i6cIyFAM+JN1lnGwNovR2Rx0iVQzggitZi6v0BcY8RFOuzTbtTO9uFrPY 0CmkHFCBuvxIA== 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.15 44/68] nvme-tcp: fix memory leak when freeing a queue Date: Tue, 30 Nov 2021 09:46:40 -0500 Message-Id: <20211130144707.944580-44-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 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 da733749192c6..f7fdf78ec34db 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1225,6 +1225,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]; @@ -1234,6 +1235,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->send_mutex); -- 2.33.0