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

Wilfred Mallawa wilfred.opensource at gmail.com
Fri May 9 16:59:05 PDT 2025


From: Wilfred Mallawa <wilfred.mallawa at wdc.com>

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 at intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202505091619.QFU1fxsd-lkp@intel.com/
Signed-off-by: Wilfred Mallawa <wilfred.mallawa at wdc.com>
---
 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




More information about the Linux-nvme mailing list