Skip to content

Commit 5572a55

Browse files
maurizio-lombardikeithbusch
authored andcommitted
nvmet-tcp: fix kernel crash if commands allocation fails
If the commands allocation fails in nvmet_tcp_alloc_cmds() the kernel crashes in nvmet_tcp_release_queue_work() because of a NULL pointer dereference. nvmet: failed to install queue 0 cntlid 1 ret 6 Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 Fix the bug by setting queue->nr_cmds to zero in case nvmet_tcp_alloc_cmd() fails. Fixes: 872d26a ("nvmet-tcp: add NVMe over TCP target driver") Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 5a6d3a6 commit 5572a55

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/nvme/target/tcp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,8 +2146,10 @@ static u16 nvmet_tcp_install_queue(struct nvmet_sq *sq)
21462146
}
21472147

21482148
queue->nr_cmds = sq->size * 2;
2149-
if (nvmet_tcp_alloc_cmds(queue))
2149+
if (nvmet_tcp_alloc_cmds(queue)) {
2150+
queue->nr_cmds = 0;
21502151
return NVME_SC_INTERNAL;
2152+
}
21512153
return 0;
21522154
}
21532155

0 commit comments

Comments
 (0)