Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ziye Yang <ziye.yang@intel.com>
To: linux-nvme@lists.infradead.org
Subject: [PATCH] nvmet/tcp: Solve coredump issue while initiator sends write CapsuleCmd
Date: Fri, 21 Aug 2020 23:02:52 +0800	[thread overview]
Message-ID: <20200821150252.40800-1-ziye.yang@intel.com> (raw)

When the initiator sneds write CapsuleCmd without incapsuledata, we
can use the queue->connect command to handle. If we do not do that,
we will have a coredump because queue->cmds are not initialized.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
---
 drivers/nvme/target/tcp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
index 9eda91162fe4..9d3eeb9338cc 100644
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -866,7 +866,11 @@ static int nvmet_tcp_handle_h2c_data_pdu(struct nvmet_tcp_queue *queue)
 	struct nvme_tcp_data_pdu *data = &queue->pdu.data;
 	struct nvmet_tcp_cmd *cmd;
 
-	cmd = &queue->cmds[data->ttag];
+	if (likely(queue->nr_cmds)) {
+		cmd = &queue->cmds[data->ttag];
+	} else {
+		cmd = &queue->connect;
+	}
 
 	if (le32_to_cpu(data->data_offset) != cmd->rbytes_done) {
 		pr_err("ttag %u unexpected data offset %u (expected %u)\n",
-- 
2.21.3


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

             reply	other threads:[~2020-08-21  5:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 15:02 Ziye Yang [this message]
2020-08-21  5:57 ` [PATCH] nvmet/tcp: Solve coredump issue while initiator sends write CapsuleCmd Sagi Grimberg
2020-08-21  6:00   ` Yang, Ziye

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=20200821150252.40800-1-ziye.yang@intel.com \
    --to=ziye.yang@intel.com \
    --cc=linux-nvme@lists.infradead.org \
    /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