[PATCH] scsi: iscsi: fix harmless double shift bug

7 views
Skip to first unread message

Dan Carpenter

unread,
Apr 21, 2022, 11:04:14 AM4/21/22
to Lee Duncan, Mike Christie, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, kernel-...@vger.kernel.org
These flags are supposed to be bit numbers. Right now they cause a
double shift bug where we use BIT(BIT(2)) instead of BIT(2).
Fortunately, the bit numbers are small and it's done consistently so it
does not cause an issue at run time.

Fixes: 5bd856256f8c ("scsi: iscsi: Merge suspend fields")
Signed-off-by: Dan Carpenter <dan.ca...@oracle.com>
---
include/scsi/libiscsi.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index d0a24779c52d..c0703cd20a99 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -54,9 +54,9 @@ enum {
#define ISID_SIZE 6

/* Connection flags */
-#define ISCSI_CONN_FLAG_SUSPEND_TX BIT(0)
-#define ISCSI_CONN_FLAG_SUSPEND_RX BIT(1)
-#define ISCSI_CONN_FLAG_BOUND BIT(2)
+#define ISCSI_CONN_FLAG_SUSPEND_TX 0
+#define ISCSI_CONN_FLAG_SUSPEND_RX 1
+#define ISCSI_CONN_FLAG_BOUND 2

#define ISCSI_ITT_MASK 0x1fff
#define ISCSI_TOTAL_CMDS_MAX 4096
--
2.20.1

Mike Christie

unread,
Apr 21, 2022, 11:38:45 AM4/21/22
to Dan Carpenter, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, kernel-...@vger.kernel.org
Thanks.

Reviewed-by: Mike Christie <michael....@oracle.com>

Lee Duncan

unread,
Apr 21, 2022, 12:14:21 PM4/21/22
to Dan Carpenter, Mike Christie, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, kernel-...@vger.kernel.org
Reviewed-by: Lee Duncan <ldu...@suse.com>

Ulrich Windl

unread,
Apr 22, 2022, 4:20:34 AM4/22/22
to michael....@oracle.com, Lee Duncan, open-iscsi, je...@linux.ibm.com, martin....@oracle.com, Chris Leech, kernel-...@vger.kernel.org, linux...@vger.kernel.org
>>> Dan Carpenter <dan.ca...@oracle.com> schrieb am 21.04.2022 um 17:03 in
Nachricht <YmFyWHf8nrrx+SHa@kili>:
Actually it's not the "flag" then, but the "flag's bit position".
Personally I think applying BIT() again is the bug, not the definition.

>
> #define ISCSI_ITT_MASK 0x1fff
> #define ISCSI_TOTAL_CMDS_MAX 4096
> --
> 2.20.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "open-iscsi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to open-iscsi+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/open-iscsi/YmFyWHf8nrrx%2BSHa%40kili.




Martin K. Petersen

unread,
Apr 25, 2022, 10:36:07 PM4/25/22
to Dan Carpenter, Lee Duncan, Mike Christie, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, kernel-...@vger.kernel.org

Dan,

> These flags are supposed to be bit numbers. Right now they cause a
> double shift bug where we use BIT(BIT(2)) instead of BIT(2).
> Fortunately, the bit numbers are small and it's done consistently so
> it does not cause an issue at run time.

Applied to 5.19/scsi-staging, thanks!

--
Martin K. Petersen Oracle Linux Engineering

Martin K. Petersen

unread,
May 2, 2022, 8:52:03 PM5/2/22
to Lee Duncan, Mike Christie, Dan Carpenter, Martin K . Petersen, James E.J. Bottomley, open-...@googlegroups.com, kernel-...@vger.kernel.org, Chris Leech, linux...@vger.kernel.org
On Thu, 21 Apr 2022 18:03:52 +0300, Dan Carpenter wrote:

> These flags are supposed to be bit numbers. Right now they cause a
> double shift bug where we use BIT(BIT(2)) instead of BIT(2).
> Fortunately, the bit numbers are small and it's done consistently so it
> does not cause an issue at run time.
>
>

Applied to 5.19/scsi-queue, thanks!

[1/1] scsi: iscsi: fix harmless double shift bug
https://git.kernel.org/mkp/scsi/c/565138ac5f8a
Reply all
Reply to author
Forward
0 new messages