Skip to content

Commit 926245c

Browse files
maurizio-lombardiChristoph Hellwig
authored andcommitted
nvmet-tcp: fix a memory leak when releasing a queue
page_frag_free() won't completely release the memory allocated for the commands, the cache page must be explicitly freed by calling __page_frag_cache_drain(). This bug can be easily reproduced by repeatedly executing the following command on the initiator: $echo 1 > /sys/devices/virtual/nvme-fabrics/ctl/nvme0/reset_controller 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 9fbfabf commit 926245c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/nvme/target/tcp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,7 @@ static void nvmet_tcp_uninit_data_in_cmds(struct nvmet_tcp_queue *queue)
14281428

14291429
static void nvmet_tcp_release_queue_work(struct work_struct *w)
14301430
{
1431+
struct page *page;
14311432
struct nvmet_tcp_queue *queue =
14321433
container_of(w, struct nvmet_tcp_queue, release_work);
14331434

@@ -1447,6 +1448,8 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)
14471448
nvmet_tcp_free_crypto(queue);
14481449
ida_simple_remove(&nvmet_tcp_queue_ida, queue->idx);
14491450

1451+
page = virt_to_head_page(queue->pf_cache.va);
1452+
__page_frag_cache_drain(page, queue->pf_cache.pagecnt_bias);
14501453
kfree(queue);
14511454
}
14521455

0 commit comments

Comments
 (0)