Skip to content

Commit a5053c9

Browse files
maurizio-lombardiChristoph Hellwig
authored andcommitted
nvme-tcp: fix memory leak when freeing a queue
Release the page frag cache when tearing down the io queues Signed-off-by: Maurizio Lombardi <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: John Meneghini <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 1d3ef9c commit a5053c9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/nvme/host/tcp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,7 @@ static int nvme_tcp_alloc_async_req(struct nvme_tcp_ctrl *ctrl)
12251225

12261226
static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
12271227
{
1228+
struct page *page;
12281229
struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl);
12291230
struct nvme_tcp_queue *queue = &ctrl->queues[qid];
12301231

@@ -1234,6 +1235,11 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
12341235
if (queue->hdr_digest || queue->data_digest)
12351236
nvme_tcp_free_crypto(queue);
12361237

1238+
if (queue->pf_cache.va) {
1239+
page = virt_to_head_page(queue->pf_cache.va);
1240+
__page_frag_cache_drain(page, queue->pf_cache.pagecnt_bias);
1241+
queue->pf_cache.va = NULL;
1242+
}
12371243
sock_release(queue->sock);
12381244
kfree(queue->pdu);
12391245
mutex_destroy(&queue->send_mutex);

0 commit comments

Comments
 (0)