[Skiboot] [PATCH 02/12] libflash/mbox-flash: Fix unintentional integer overflow (CID 142226)
Cyril Bur
cyril.bur at au1.ibm.com
Thu Aug 3 16:45:41 AEST 2017
Fixes: CID 142226 (#1 of 1):
overflow_before_widen: Potentially overflowing expression
`1 << mbox_flash->shift` with type int (32 bits, signed) is evaluated using
32-bit arithmetic, and then used in a context that expects an expression
of type uint64_t (64 bits, unsigned).
Fixes: CID 142226
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
libflash/mbox-flash.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index 7491d3b1..950e24f0 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -141,9 +141,9 @@ static int lpc_window_write(struct mbox_flash_data *mbox_flash, uint32_t pos,
return 0;
}
-__unused static uint64_t mbox_flash_mask(struct mbox_flash_data *mbox_flash)
+static uint64_t mbox_flash_mask(struct mbox_flash_data *mbox_flash)
{
- return (1 << mbox_flash->shift) - 1;
+ return (1ULL << mbox_flash->shift) - 1;
}
__unused static uint8_t msg_get_u8(struct bmc_mbox_msg *msg, int i)
--
2.13.3
More information about the Skiboot
mailing list