[PATCH] nvmet: nvmet_sq_init(): fix use of uninitialized variable

From: Wilfred Mallawa
Date: Fri May 09 2025 - 20:00:54 EST


From: Wilfred Mallawa <wilfred.mallawa@xxxxxxx>

This fixes a bug where an uninitialized return value is used in
nvmet_sq_init().

Fixes: 206372d7c565 ("nvmet: support completion queue sharing")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202505091619.QFU1fxsd-lkp@xxxxxxxxx/
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@xxxxxxx>
---
drivers/nvme/target/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 042039011d7c..e30545586302 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1012,7 +1012,7 @@ int nvmet_sq_init(struct nvmet_sq *sq, struct nvmet_cq *cq)
int ret;

if (!nvmet_cq_get(cq))
- return ret;
+ return -EINVAL;

ret = percpu_ref_init(&sq->ref, nvmet_sq_free, 0, GFP_KERNEL);
if (ret) {
--
2.49.0