public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
	linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH] nvme-tcp: check for allocated queue in nvme_tcp_get_address()
Date: Tue,  7 Feb 2023 15:55:48 +0100	[thread overview]
Message-ID: <20230207145548.113618-1-hare@suse.de> (raw)

We need to check if the queue is allocated, otherwise we get
a kernel crash as 'queue->sock' is not allocated.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/nvme/host/tcp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 4ddf3e7b252a..487ea3e8b6c4 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -2859,6 +2859,9 @@ static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
 	struct sockaddr_storage src_addr;
 	int ret, len;
 
+	if (!test_bit(NVME_TCP_Q_ALLOCATED, &queue->flags))
+		return -EINVAL;
+
 	len = nvmf_get_address(ctrl, buf, size);
 
 	ret = kernel_getsockname(queue->sock, (struct sockaddr *)&src_addr);
-- 
2.35.3



             reply	other threads:[~2023-02-07 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 14:55 Hannes Reinecke [this message]
2023-02-08  6:27 ` [PATCH] nvme-tcp: check for allocated queue in nvme_tcp_get_address() Christoph Hellwig
2023-02-13 10:50   ` Sagi Grimberg

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=20230207145548.113618-1-hare@suse.de \
    --to=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox