Skip to content

Commit 2fa8961

Browse files
Hannes Reineckekeithbusch
authored andcommitted
nvmet-tcp: fixup hang in nvmet_tcp_listen_data_ready()
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 <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent d1877cc commit 2fa8961

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/nvme/target/tcp.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,14 +2004,13 @@ static void nvmet_tcp_listen_data_ready(struct sock *sk)
20042004

20052005
trace_sk_data_ready(sk);
20062006

2007+
if (sk->sk_state != TCP_LISTEN)
2008+
return;
2009+
20072010
read_lock_bh(&sk->sk_callback_lock);
20082011
port = sk->sk_user_data;
2009-
if (!port)
2010-
goto out;
2011-
2012-
if (sk->sk_state == TCP_LISTEN)
2012+
if (port)
20132013
queue_work(nvmet_wq, &port->accept_work);
2014-
out:
20152014
read_unlock_bh(&sk->sk_callback_lock);
20162015
}
20172016

0 commit comments

Comments
 (0)