Skip to content

Commit

Permalink
nvmet-tcp: fix memory leak when performing a controller reset
Browse files Browse the repository at this point in the history
If a reset controller is executed while the initiator
is performing some I/O the driver may leak the memory allocated
for the commands' iovec.

Make sure that nvmet_tcp_uninit_data_in_cmds() releases
all the memory.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Maurizio Lombardi authored and Christoph Hellwig committed Nov 23, 2021
1 parent 69b85e1 commit af21250
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/nvme/target/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,10 @@ static void nvmet_tcp_uninit_data_in_cmds(struct nvmet_tcp_queue *queue)

for (i = 0; i < queue->nr_cmds; i++, cmd++) {
if (nvmet_tcp_need_data_in(cmd))
nvmet_tcp_finish_cmd(cmd);
nvmet_req_uninit(&cmd->req);

nvmet_tcp_unmap_pdu_iovec(cmd);
nvmet_tcp_free_cmd_buffers(cmd);
}

if (!queue->nr_cmds && nvmet_tcp_need_data_in(&queue->connect)) {
Expand Down

0 comments on commit af21250

Please sign in to comment.