LF-3622: mtd: nand: gpmi: fix the unintentional integer overflow issue
authorHan Xu <han.xu@nxp.com>
Mon, 29 Mar 2021 18:14:08 +0000 (13:14 -0500)
committerHan Xu <han.xu@nxp.com>
Wed, 5 May 2021 03:25:51 +0000 (22:25 -0500)
cast the variable from int to loff_t to avoid potential overflow issue,
reported by coverity. CID 17332.

Signed-off-by: Han Xu <han.xu@nxp.com>
Reviewed-by: Frank Li <frank.li@nxp.com>
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c

index d0079c1..d7a157a 100644 (file)
@@ -2216,7 +2216,7 @@ static int mx23_boot_init(struct gpmi_nand_data  *this)
                 */
                chipnr = block >> (chip->chip_shift - chip->phys_erase_shift);
                page = block << (chip->phys_erase_shift - chip->page_shift);
-               byte = block <<  chip->phys_erase_shift;
+               byte = (loff_t)block <<  chip->phys_erase_shift;
 
                /* Send the command to read the conventional block mark. */
                nand_select_target(chip, chipnr);