nvmet-tcp: fix a memory leak when releasing a queue
Subsystems (2)
PATCH 1/1 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
--- drivers/nvme/target/tcp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/nvme/target/tcp.c +3 -0
@@ -1428,6 +1428,7 @@ static void nvmet_tcp_uninit_data_in_cmds(struct nvmet_tcp_queue *queue)static void nvmet_tcp_release_queue_work (struct work_struct *w) { +struct page *page;struct nvmet_tcp_queue *queue = container_of(w, struct nvmet_tcp_queue, release_work);
@@ -1447,6 +1448,8 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w)nvmet_tcp_free_crypto (queue);ida_simple_remove (&nvmet_tcp_queue_ida, queue->idx); + page =virt_to_head_page (queue->pf_cache.va); +__page_frag_cache_drain (page, queue->pf_cache.pagecnt_bias);kfree (queue); }
Signature · 1 line
2.27.0
Quoted 11 lines
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_controllerSigned-off-by Maurizio Lombardi <[email protected]>Reviewed-by John Meneghini <[email protected]>
This came a long a number of times before, thanks for fixing this.
Thanks,
applied to nvme-5.15.