Skip to contentSkip to conversation

nvmet: return proper error code from discovery ctrl

PATCH Applied Hou Pu 2 participants 2 messages Mar 31, 2021 – Apr 2, 2021

Subsystems (2)
lore
Share & tools
lore

Hou Pu

author
#0 lore raw

PATCH v2 1/1 nvmet: return proper error code from discovery ctrl

Return NVME_SC_INVALID_FIELD from discovery controller like normal controller when executing identify or get log page command.

---
v2:
* Drop patch 2/2 from the series which is already fixed for 5.13.
* Modify commit message suggested by Chaitanya.
* Add "Reviewed-by: Chaitanya Kulkarni <[email protected]>".

---
 drivers/nvme/target/discovery.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/target/discovery.c +4 -2
index 682854e0e079..4845d12e374a 100644
@@ -178,12 +178,14 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
 	if (req->cmd->get_log_page.lid != NVME_LOG_DISC) {
 		req->error_loc =
 			offsetof(struct nvme_get_log_page_command, lid);
-		status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 		goto out;
 	}
 
 	/* Spec requires dword aligned offsets */
 	if (offset & 0x3) {
+		req->error_loc =
+			offsetof(struct nvme_get_log_page_command, lpo);
 		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 		goto out;
 	}
@@ -250,7 +252,7 @@ static void nvmet_execute_disc_identify(struct nvmet_req *req)
 
 	if (req->cmd->identify.cns != NVME_ID_CNS_CTRL) {
 		req->error_loc = offsetof(struct nvme_identify, cns);
-		status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 		goto out;
 	}
 
Signature · 7 lines
2.28.0


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