Skip to contentSkip to conversation

nvme-rdma: fix error code in nvme_rdma_create_ctrl()

PATCH Applied Dan Carpenter 2 participants 2 messages Jun 14, 2017 – Jun 15, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-rdma: fix error code in nvme_rdma_create_ctrl()

We accidentally return ERR_PTR(0) which is NULL. The caller isn't explicitly checking for that but I couldn't immediately spot whether this would lead to a NULL dereference. Anyway, we can fix add an error code easily enough.

drivers/nvme/host/rdma.c +2 -0
index e84a74479dd8..8456cb6e2a70 100644
@@ -1940,12 +1940,14 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
 	/* sanity check icdoff */
 	if (ctrl->ctrl.icdoff) {
 		dev_err(ctrl->ctrl.device, "icdoff is not supported!\n");
+		ret = -EINVAL;
 		goto out_remove_admin_queue;
 	}
 
 	/* sanity check keyed sgls */
 	if (!(ctrl->ctrl.sgls & (1 << 20))) {
 		dev_err(ctrl->ctrl.device, "Mandatory keyed sgls are not support\n");
+		ret = -EINVAL;
 		goto out_remove_admin_queue;
 	}
 
#1 lore raw
Quoted 6 lines · Dan Carpenter

We accidentally return ERR_PTR(0) which is NULL. The caller isn't explicitly checking for that but I couldn't immediately spot whether this would lead to a NULL dereference. Anyway, we can fix add an error code easily enough.

Thanks Dan,

applied to nvme-4.13.