Skip to content

Commit 502707c

Browse files
committed
mi: check response status after each submit()
Add a few checks to the callers of nvme_mi_submit(), to ensure that the response status is zero before considering the data valid. In the existing cases, we'd currently fail for response length mismatches, but we want to be explicit about the check. Signed-off-by: Jeremy Kerr <[email protected]>
1 parent c13abc6 commit 502707c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/nvme/mi.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ int nvme_mi_admin_identify_partial(nvme_mi_ctrl_t ctrl,
352352
if (rc)
353353
return rc;
354354

355+
if (resp_hdr.status)
356+
return resp_hdr.status;
357+
355358
if (args->result)
356359
*args->result = le32_to_cpu(resp_hdr.cdw0);
357360

@@ -593,9 +596,11 @@ static int nvme_mi_read_data(nvme_mi_ep_t ep, __u32 cdw0,
593596
if (rc)
594597
return rc;
595598

599+
if (resp_hdr.status)
600+
return resp_hdr.status;
601+
596602
*data_len = resp.data_len;
597603

598-
/* check status, map to return value */
599604
return 0;
600605
}
601606

@@ -713,6 +718,9 @@ int nvme_mi_mi_subsystem_health_status_poll(nvme_mi_ep_t ep, bool clear,
713718
if (rc)
714719
return rc;
715720

721+
if (resp_hdr.status)
722+
return resp_hdr.status;
723+
716724
if (resp.data_len != sizeof(*sshs)) {
717725
nvme_msg(ep->root, LOG_WARNING,
718726
"MI Subsystem Health Status length mismatch: "
@@ -721,7 +729,6 @@ int nvme_mi_mi_subsystem_health_status_poll(nvme_mi_ep_t ep, bool clear,
721729
return -EIO;
722730
}
723731

724-
/* check status, map to return value */
725732
return 0;
726733
}
727734

0 commit comments

Comments
 (0)