Skip to contentSkip to conversation

driver: nvme: fix missing error code

PATCH NAK Dongliang Mu 2 participants 3 messages Nov 30, 2021 – Dec 1, 2021 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver: nvme: fix missing error code

Smatch reports:

drivers/nvme/host/multipath.c:865 nvme_mpath_init_identify() warn: missing error code 'error'

In one error handling path of nvme_mpath_init_identify(Line 865), error is not initialized as an errno.

Fix this by assigning error to -EINVAL.

---
 drivers/nvme/host/multipath.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/host/multipath.c +1 -0
index 7f2071f2460c..2cbeb6d6b064 100644
@@ -862,6 +862,7 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 			"ANA log page size (%zd) larger than MDTS (%zd).\n",
 			ana_log_size, max_transfer_size);
 		dev_err(ctrl->device, "disabling ANA support.\n");
+		error = -EINVAL;
 		goto out_uninit;
 	}
 	if (ana_log_size > ctrl->ana_log_size) {
Signature · 1 line
2.25.1
maintainer NAK
#1 lore raw
Quoted 9 lines · Dongliang Mu

Smatch reports:

drivers/nvme/host/multipath.c:865 nvme_mpath_init_identify() warn: missing error code 'error'

In one error handling path of nvme_mpath_init_identify(Line 865), error is not initialized as an errno.

Fix this by assigning error to -EINVAL.

Nak, the code is correct as-is. Returning a negetive error will abort the initialization process. We don't need ANA support in order to manage this controller, so failing a controller for an optional condition isn't helpful.

The other parts of this function returning negetive errors should be fixed to return 0, though.

Quoted 20 lines
---
 drivers/nvme/host/multipath.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/host/multipath.c +1 -0
index 7f2071f2460c..2cbeb6d6b064 100644
@@ -862,6 +862,7 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 			"ANA log page size (%zd) larger than MDTS (%zd).\n",
 			ana_log_size, max_transfer_size);
 		dev_err(ctrl->device, "disabling ANA support.\n");
+		error = -EINVAL;
 		goto out_uninit;
 	}
 	if (ana_log_size > ctrl->ana_log_size) {
Signature · 1 line
2.25.1
#2 lore raw
Quoted 10 lines · Keith Busch
Quoted 8 lines · Dongliang Mu

Smatch reports:

drivers/nvme/host/multipath.c:865 nvme_mpath_init_identify() warn: missing error code 'error'

In one error handling path of nvme_mpath_init_identify(Line 865), error is not initialized as an errno.

Quoted 7 lines
Quoted 1 line

Fix this by assigning error to -EINVAL.

Nak, the code is correct as-is. Returning a negetive error will abort the initialization process. We don't need ANA support in order to manage this controller, so failing a controller for an optional condition isn't helpful.

OK, I see. Let's ignore this patch.

Quoted 2 lines

The other parts of this function returning negetive errors should be fixed to return 0, though.

Do I need to modify the error value to zero and submit another patch? Or you will take care of it?

Quoted 21 lines
Quoted 21 lines
---
 drivers/nvme/host/multipath.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/host/multipath.c +1 -1
index 7f2071f2460c..2cbeb6d6b064 100644
@@ -862,6 +862,7 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
                      "ANA log page size (%zd) larger than MDTS (%zd).\n",
                      ana_log_size, max_transfer_size);
              dev_err(ctrl->device, "disabling ANA support.\n");
+             error = -EINVAL;
              goto out_uninit;
      }
      if (ana_log_size > ctrl->ana_log_size) {
--

2.25.1