[PATCH] mtd: rawnand: gpmi: Fix unintentional integer overflow

Stefan Ghetu stefan.ghetu at nxp.com
Thu Nov 5 01:59:35 PST 2026


From: Han Xu <han.xu at nxp.com>

Cast block to loff_t before shifting, so that the shift is done in
64-bit arithmetic and the potential integer overflow is avoided.
Reported by Coverity.

Fixes: 10a2bcae9926 ("mtd: add the common code for GPMI-NAND controller driver")
Signed-off-by: Han Xu <han.xu at nxp.com>
Signed-off-by: Stefan Ghetu <stefan.ghetu at nxp.com>
---
 drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
index 0f1528710a6a..e21e407f86c0 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
@@ -2236,7 +2236,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);
-- 
2.34.1




More information about the linux-mtd mailing list