[PATCH] nvmet-tcp: fixup hang in nvmet_tcp_listen_data_ready()
Maurizio Lombardi
mlombard at bsdbackstore.eu
Fri Sep 26 05:48:02 PDT 2025
On Mon Aug 18, 2025 at 11:32 AM CEST, hare wrote:
> From: Hannes Reinecke <hare at kernel.org>
>
> 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.
Ping, I guess this patch has been forgotten
Maurizio
>
> Signed-off-by: Hannes Reinecke <hare at kernel.org>
> Tested-by: Yi Zhang <yi.zhang at redhat.com>
> ---
> drivers/nvme/target/tcp.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
> index 470bf37e5a63..2e9a3e698b70 100644
> --- a/drivers/nvme/target/tcp.c
> +++ b/drivers/nvme/target/tcp.c
> @@ -1992,14 +1992,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);
> }
>
More information about the Linux-nvme
mailing list