From: Wilfred Mallawa <wilfred.opensource@gmail.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Hannes Reinecke <hare@suse.de>,
Damien Le'Moal <dlemoal@kernel.org>,
Wilfred Mallawa <wilfred.mallawa@wdc.com>
Subject: [PATCH] nvme/tcp: release socket on sock_alloc_file() failure
Date: Tue, 12 May 2026 20:28:32 +1000 [thread overview]
Message-ID: <20260512102831.3593121-2-wilfred.opensource@gmail.com> (raw)
From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
If sock_alloc_file() fails after a sock_create_kern() in
nvme_tcp_alloc_queue(), the socket is not released.
Add sock_release() to release the socket if sock_alloc_file() fails.
Fixes: e40d4eb84089eae1 ("nvme-tcp: allocate socket file")
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
---
drivers/nvme/host/tcp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 8e5421d2e8b9..f4b9d8acc7b1 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1820,6 +1820,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
sock_file = sock_alloc_file(queue->sock, O_CLOEXEC, NULL);
if (IS_ERR(sock_file)) {
ret = PTR_ERR(sock_file);
+ sock_release(queue->sock);
+ queue->sock = NULL;
goto err_destroy_mutex;
}
--
2.54.0
next reply other threads:[~2026-05-12 10:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 10:28 Wilfred Mallawa [this message]
2026-05-12 14:04 ` [PATCH] nvme/tcp: release socket on sock_alloc_file() failure Hannes Reinecke
2026-05-12 22:03 ` Sagi Grimberg
2026-05-15 4:40 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260512102831.3593121-2-wilfred.opensource@gmail.com \
--to=wilfred.opensource@gmail.com \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=wilfred.mallawa@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.