Skip to contentSkip to conversation

nvmet: fix return status of RMI log page on allocation failure

PATCH In review Guixin Liu 3 participants 3 messages Jul 29

Subsystems (2)
lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

PATCH 1/4 nvmet: fix return status of RMI log page on allocation failure

nvmet_execute_get_log_page_rmi() leaves 'status' holding NVME_SC_SUCCESS (set by the successful nvmet_req_find_ns() call) when the kzalloc() for the log buffer fails. It then jumps to the out label and completes the request with a success status, so the host is told the command succeeded while no data was transferred.

Initialize 'status' to NVME_SC_INTERNAL, matching the smart log handler, so an allocation failure is reported as an internal error.

Fixes 5fd075cdaf36 ("nvmet: implement rotational media information log")
---
 drivers/nvme/target/admin-cmd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +3 -1
index 01b799e92ae6..0b24d31f966d 100644
@@ -309,8 +309,10 @@ static void nvmet_execute_get_log_page_rmi(struct nvmet_req *req)
 	}
 
 	log = kzalloc_obj(*log);
-	if (!log)
+	if (!log) {
+		status = NVME_SC_INTERNAL;
 		goto out;
+	}
 
 	log->endgid = req->cmd->get_log_page.lsi;
 	disk = req->ns->bdev->bd_disk;
Signature · 1 line
2.43.7
maintainer Reviewed-by on v1 1/4
#1 lore raw
Quoted 11 lines · Guixin Liu

nvmet_execute_get_log_page_rmi() leaves 'status' holding NVME_SC_SUCCESS (set by the successful nvmet_req_find_ns() call) when the kzalloc() for the log buffer fails. It then jumps to the out label and completes the request with a success status, so the host is told the command succeeded while no data was transferred.

Initialize 'status' to NVME_SC_INTERNAL, matching the smart log handler, so an allocation failure is reported as an internal error.

Fixes 5fd075cdaf36 ("nvmet: implement rotational media information log")

Looks good:

maintainer
#2 lore raw
In reply to Guixin Liu

Thanks, series applied to nvme-7.3.

For future refernce, please use something sane like 'git send-email' to submit a patch series. This one is split across different threads.