summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHannes Reinecke <hare@kernel.org>2025-08-18 11:32:45 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-02-11 13:39:12 +0100
commitf532b29b0e313f42b964014038b0f52899b240ec (patch)
tree7acea1bf2ecaa6ca9d9ad96ff2717b406ae740cf /drivers
parent7c54d3f5ebbc5982daaa004260242dc07ac943ea (diff)
downloadlinux-f532b29b0e313f42b964014038b0f52899b240ec.tar.gz
linux-f532b29b0e313f42b964014038b0f52899b240ec.tar.bz2
linux-f532b29b0e313f42b964014038b0f52899b240ec.zip
nvmet-tcp: fixup hang in nvmet_tcp_listen_data_ready()
[ Upstream commit 2fa8961d3a6a1c2395d8d560ffed2c782681bade ] When the socket is closed while in TCP_LISTEN a callback is run to flush all outstanding packets, which in turns calls nvmet_tcp_listen_data_ready() with the sk_callback_lock held. So we need to check if we are in TCP_LISTEN before attempting to get the sk_callback_lock() to avoid a deadlock. Link: https://lore.kernel.org/linux-nvme/CAHj4cs-zu7eVB78yUpFjVe2UqMWFkLk8p+DaS3qj+uiGCXBAoA@mail.gmail.com/ Tested-by: Yi Zhang <yi.zhang@redhat.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Hannes Reinecke <hare@kernel.org> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/nvme/target/tcp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index ee19eeb47dd2..4d1f260ae60a 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1757,14 +1757,13 @@ static void nvmet_tcp_listen_data_ready(struct sock *sk)
trace_sk_data_ready(sk);
+ if (sk->sk_state != TCP_LISTEN)
+ return;
+
read_lock_bh(&sk->sk_callback_lock);
port = sk->sk_user_data;
- if (!port)
- goto out;
-
- if (sk->sk_state == TCP_LISTEN)
+ if (port)
queue_work(nvmet_wq, &port->accept_work);
-out:
read_unlock_bh(&sk->sk_callback_lock);
}