[PATCH] zloop: fix the error code in the blk_mq_alloc_disk message
From: shao.mingyin
Date: Sat Oct 31 2026 - 10:18:00 EST
From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
When blk_mq_alloc_disk() fails, "ret" still holds the zero returned by the
preceding blk_mq_alloc_tag_set() call, so the error message always reports
"err=0". Save PTR_ERR(zlo->disk) in "ret" before printing it, like the
blk_mq_alloc_tag_set() and add_disk() failure paths do.
Fixes: eb0570c7df23 ("block: new zoned loop block device driver")
Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
---
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 9145e0f98d56..b7cfd5a39f16 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -1343,8 +1343,8 @@ static int zloop_ctl_add(struct zloop_options *opts)
zlo->disk = blk_mq_alloc_disk(&zlo->tag_set, &lim, zlo);
if (IS_ERR(zlo->disk)) {
- pr_err("blk_mq_alloc_disk failed (err=%d)\n", ret);
ret = PTR_ERR(zlo->disk);
+ pr_err("blk_mq_alloc_disk failed (err=%d)\n", ret);
goto out_cleanup_tags;
}
zlo->disk->flags = GENHD_FL_NO_PART;