Skip to contentSkip to conversation

nvme: verify MNAN value if ANA is enabled

PATCH Applied Daniel Wagner 2 participants 2 messages Jun 7, 2021 – Jun 8, 2021 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme: verify MNAN value if ANA is enabled

The controller is required to have a non-zero MNAN value if it supports ANA:

If the controller supports Asymmetric Namespace Access Reporting, then this field shall be set to a non-zero value that is less than or equal to the NN value.

---

v2: - moved the check to nvme_mpath_init_identify
- added reviewed tags

 drivers/nvme/host/multipath.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/nvme/host/multipath.c +7 -0
index a501917d4c6e..23573fe3fc7d 100644
@@ -813,6 +813,13 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	    !(ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA))
 		return 0;
 
+	if (!ctrl->max_namespaces ||
+	    ctrl->max_namespaces > le32_to_cpu(id->nn)) {
+		dev_err(ctrl->device,
+			"Invalid MNAN value %u\n", ctrl->max_namespaces);
+		return -EINVAL;
+	}
+
 	ctrl->anacap = id->anacap;
 	ctrl->anatt = id->anatt;
 	ctrl->nanagrpid = le32_to_cpu(id->nanagrpid);
Signature · 1 line
2.29.2