]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvmet-tcp: fix kernel crash if commands allocation fails
authorMaurizio Lombardi <mlombard@redhat.com>
Wed, 21 Aug 2024 14:28:26 +0000 (16:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:11:44 +0000 (11:11 +0200)
commit489f2913a63f528cfe3f21722583fb981967ecda
tree4cf49ec5d7bcbc589a67a79769b320db8b773426
parent585c598082e1935c73eee03e62dad69a639a49b0
nvmet-tcp: fix kernel crash if commands allocation fails

[ Upstream commit 5572a55a6f830ee3f3a994b6b962a5c327d28cb3 ]

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: 872d26a391da ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/target/tcp.c