mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: gpmi: Fix unintentional integer overflow
@ 2026-11-05  9:59 Stefan Ghetu
  2026-11-05 17:30 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Ghetu @ 2026-11-05  9:59 UTC (permalink / raw)
  To: han.xu, miquel.raynal
  Cc: richard, daniel.baluta, vigneshr, imx, linux-mtd, linux-kernel,
	Stefan Ghetu

From: Han Xu <han.xu@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@nxp.com>
Signed-off-by: Stefan Ghetu <stefan.ghetu@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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-05 17:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05  9:59 [PATCH] mtd: rawnand: gpmi: Fix unintentional integer overflow Stefan Ghetu
2026-11-05 17:30 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®