]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: bnx2fc: fix incorrect cast to u64 on shift operation
authorColin Ian King <colin.king@canonical.com>
Sat, 4 May 2019 16:48:29 +0000 (17:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jun 2019 06:18:03 +0000 (08:18 +0200)
[ Upstream commit d0c0d902339249c75da85fd9257a86cbb98dfaa5 ]

Currently an int is being shifted and the result is being cast to a u64
which leads to undefined behaviour if the shift is more than 31 bits. Fix
this by casting the integer value 1 to u64 before the shift operation.

Addresses-Coverity: ("Bad shift operation")
Fixes: 7b594769120b ("[SCSI] bnx2fc: Handle REC_TOV error code from firmware")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/bnx2fc/bnx2fc_hwi.c

index e8ae4d671d233b8a532cf1cb1fc56faaa3a16979..097305949a955c87ad67eceb096992ffb50565ec 100644 (file)
@@ -830,7 +830,7 @@ ret_err_rqe:
                        ((u64)err_entry->data.err_warn_bitmap_hi << 32) |
                        (u64)err_entry->data.err_warn_bitmap_lo;
                for (i = 0; i < BNX2FC_NUM_ERR_BITS; i++) {
-                       if (err_warn_bit_map & (u64) (1 << i)) {
+                       if (err_warn_bit_map & ((u64)1 << i)) {
                                err_warn = i;
                                break;
                        }