]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.183/scsi-bnx2fc-fix-incorrect-cast-to-u64-on-shift-opera.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.183 / scsi-bnx2fc-fix-incorrect-cast-to-u64-on-shift-opera.patch
1 From dcd64802cff863b28cf08e3ca092acb2fddf96ff Mon Sep 17 00:00:00 2001
2 From: Colin Ian King <colin.king@canonical.com>
3 Date: Sat, 4 May 2019 17:48:29 +0100
4 Subject: scsi: bnx2fc: fix incorrect cast to u64 on shift operation
5
6 [ Upstream commit d0c0d902339249c75da85fd9257a86cbb98dfaa5 ]
7
8 Currently an int is being shifted and the result is being cast to a u64
9 which leads to undefined behaviour if the shift is more than 31 bits. Fix
10 this by casting the integer value 1 to u64 before the shift operation.
11
12 Addresses-Coverity: ("Bad shift operation")
13 Fixes: 7b594769120b ("[SCSI] bnx2fc: Handle REC_TOV error code from firmware")
14 Signed-off-by: Colin Ian King <colin.king@canonical.com>
15 Acked-by: Saurav Kashyap <skashyap@marvell.com>
16 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
17 Signed-off-by: Sasha Levin <sashal@kernel.org>
18 ---
19 drivers/scsi/bnx2fc/bnx2fc_hwi.c | 2 +-
20 1 file changed, 1 insertion(+), 1 deletion(-)
21
22 diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
23 index 5ff9f89c17c7..39b2f60149d9 100644
24 --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
25 +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
26 @@ -829,7 +829,7 @@ ret_err_rqe:
27 ((u64)err_entry->data.err_warn_bitmap_hi << 32) |
28 (u64)err_entry->data.err_warn_bitmap_lo;
29 for (i = 0; i < BNX2FC_NUM_ERR_BITS; i++) {
30 - if (err_warn_bit_map & (u64) (1 << i)) {
31 + if (err_warn_bit_map & ((u64)1 << i)) {
32 err_warn = i;
33 break;
34 }
35 --
36 2.20.1
37