Skip to contentSkip to conversation

ublk_drv: fix double shift bug

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 26, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ublk_drv: fix double shift bug

The test/clear_bit() functions take a bit number, but this code is passing as shifted value. It's the equivalent of saying BIT(BIT(0)) instead of just BIT(0).

This doesn't affect runtime because numbers are small and it's done consistently.

Fixes fa362045564e ("ublk: simplify ublk_ch_open and ublk_ch_release")
---
 drivers/block/ublk_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ublk_drv.c +2 -2
index f058f40b639c..67efad976205 100644
@@ -124,8 +124,8 @@ struct ublk_device {
 	struct cdev		cdev;
 	struct device		cdev_dev;
 
-#define UB_STATE_OPEN		(1 << 0)
-#define UB_STATE_USED		(1 << 1)
+#define UB_STATE_OPEN		0
+#define UB_STATE_USED		1
 	unsigned long		state;
 	int			ub_number;
 
Signature · 1 line
2.35.1
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 8 lines · Dan Carpenter

The test/clear_bit() functions take a bit number, but this code is passing as shifted value. It's the equivalent of saying BIT(BIT(0)) instead of just BIT(0).

This doesn't affect runtime because numbers are small and it's done consistently.

[...]

Applied, thanks!

[1/1] ublk_drv: fix double shift bug

      commit: 8d9fdb6011b4d413271eba3a62e10f89efecc419

Best regards,

Signature · 1 line
Jens Axboe