All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvmet-tcp: check return value of nvmet_tcp_set_queue_sock
@ 2026-05-26  9:28 Geliang Tang
  2026-05-26 17:05 ` Chaitanya Kulkarni
  2026-05-27 14:51 ` Keith Busch
  0 siblings, 2 replies; 3+ messages in thread
From: Geliang Tang @ 2026-05-26  9:28 UTC (permalink / raw)
  To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni,
	Hannes Reinecke, Keith Busch, Maurizio Lombardi
  Cc: Geliang Tang, linux-nvme, Hannes Reinecke

From: Geliang Tang <tanggeliang@kylinos.cn>

The return value of nvmet_tcp_set_queue_sock() is currently ignored in
nvmet_tcp_tls_handshake_done(). If it fails (e.g., due to the socket
not being in TCP_ESTABLISHED state), the socket callbacks will not be
properly set, leading to queue and socket leakage.

Fix this by capturing the return value and calling
nvmet_tcp_schedule_release_queue() on failure to ensure proper cleanup.

Fixes: 675b453e0241 ("nvmet-tcp: enable TLS handshake upcall")
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
v2:
 - add Hannes's reviewed tag.
 - drop patch 2 in v1 as Maurizio suggested.
v1:
 - https://patchwork.kernel.org/project/linux-nvme/cover/cover.1779170418.git.tanggeliang@kylinos.cn/
---
 drivers/nvme/target/tcp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 20f150d17a96..88291d45e162 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -1844,10 +1844,11 @@ static void nvmet_tcp_tls_handshake_done(void *data, int status,
 	if (!status)
 		status = nvmet_tcp_tls_key_lookup(queue, peerid);
 
+	if (!status)
+		status = nvmet_tcp_set_queue_sock(queue);
+
 	if (status)
 		nvmet_tcp_schedule_release_queue(queue);
-	else
-		nvmet_tcp_set_queue_sock(queue);
 	kref_put(&queue->kref, nvmet_tcp_release_queue);
 }
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-27 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26  9:28 [PATCH v2] nvmet-tcp: check return value of nvmet_tcp_set_queue_sock Geliang Tang
2026-05-26 17:05 ` Chaitanya Kulkarni
2026-05-27 14:51 ` Keith Busch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.