Skip to contentSkip to conversation

nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81

PATCH New Amit 1 participant 1 message Dec 5, 2019

Subsystems (2)
lore
Share & tools
lore

Amit

author
#0 lore raw

PATCH 1/1 nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81

From: Amit Engel <[email protected]>

In feature id 0x81 NVME_FEAT_HOST_ID, nvmet_copy_to_sgl is called req->data_len shall hold a non-zero value which is 'sizeof(req->sq->ctrl->hostid)'

---
 drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +10 -1
index 56c21b501185..f09d5fdc995f 100644
@@ -24,6 +24,15 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd)
 	return len;
 }
 
+u32 nvmet_feature_data_len(struct nvmet_req *req)
+{
+	u8 feature = req->cmd->common.cdw10 & 0xff;
+
+	if (feature == NVME_FEAT_HOST_ID)
+		return sizeof(req->sq->ctrl->hostid);
+	return 0;
+}
+
 u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
 {
 	return le64_to_cpu(cmd->get_log_page.lpo);
@@ -778,7 +787,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
 	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
 	u16 status = 0;
 
-	if (!nvmet_check_data_len(req, 0))
+	if (!nvmet_check_data_len(req, nvmet_feature_data_len(req))
 		return;
 
 	switch (cdw10 & 0xff) {
Signature · 7 lines
2.16.5


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme