Skip to contentSkip to conversation

ublk_drv: initialize ret variable

PATCH In review Tom Rix 2 participants 2 messages Jul 16, 2022

Subsystems (2)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 ublk_drv: initialize ret variable

clang build fails with
drivers/block/ublk_drv.c:1304:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

When the call to ublk_get_device_from_id() fails, ret is used without being initized. So initialize.

Fixes 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/ublk_drv.c +1 -1
index 52fd0af8a4f2..4d1199c98026 100644
@@ -1298,7 +1298,7 @@ static int ublk_ctrl_get_queue_affinity(struct io_uring_cmd *cmd)
 	struct ublk_device *ub;
 	unsigned long queue;
 	unsigned int retlen;
-	int ret;
+	int ret = -ENODEV;
 
 	ub = ublk_get_device_from_id(header->dev_id);
 	if (!ub)
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 5 lines · Tom Rix

clang build fails with
drivers/block/ublk_drv.c:1304:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

When the call to ublk_get_device_from_id() fails, ret is used without being initized. So initialize.

Should already be fixed:

https://git.kernel.dk/cgit/linux-block/commit/?h=for-5.20/block&id=f2450f8a2c1ec3e88d6674f747b913aa5f21fa59

Signature · 1 line
Jens Axboe