[PATCH] nvme-tcp-offload: Fix error code in nvme_tcp_ofld_create_ctrl()

From: Dan Carpenter
Date: Wed Jun 09 2021 - 07:22:07 EST


Return an error pointer if try_module_get() fails. Currently it returns
NULL.

Fixes: 4b8178ec5794 ("nvme-tcp-offload: Add device scan implementation")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
drivers/nvme/host/tcp-offload.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/tcp-offload.c b/drivers/nvme/host/tcp-offload.c
index c76822e5ada7..c07f84a7e697 100644
--- a/drivers/nvme/host/tcp-offload.c
+++ b/drivers/nvme/host/tcp-offload.c
@@ -1215,7 +1215,7 @@ nvme_tcp_ofld_create_ctrl(struct device *ndev, struct nvmf_ctrl_options *opts)
/* Increase driver refcnt */
if (!try_module_get(dev->ops->module)) {
pr_err("try_module_get failed\n");
- dev = NULL;
+ rc = -ENODEV;
goto out_free_ctrl;
}

--
2.30.2