diff mbox series

ublk_drv: fix double shift bug

Message ID Yt/2R/+MJf/MSoyl@kili (mailing list archive)
State New, archived
Headers show
Series ublk_drv: fix double shift bug | expand

Commit Message

Dan Carpenter July 26, 2022, 2:12 p.m. UTC
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/block/ublk_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig July 26, 2022, 5:44 p.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

although as-is I would not call it a bug yet as we're not going out
of unsigned long range yet.
Jens Axboe July 26, 2022, 6:30 p.m. UTC | #2
On Tue, 26 Jul 2022 17:12:23 +0300, Dan Carpenter wrote:
> 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,
diff mbox series

Patch

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index f058f40b639c..67efad976205 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -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;