From: Stefan Ghetu <stefan.ghetu@nxp.com>
To: han.xu@nxp.com, miquel.raynal@bootlin.com
Cc: richard@nod.at, daniel.baluta@nxp.com, vigneshr@ti.com,
imx@lists.linux.dev, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org, Stefan Ghetu <stefan.ghetu@nxp.com>
Subject: [PATCH] mtd: rawnand: gpmi: Fix unintentional integer overflow
Date: Thu, 5 Nov 2026 11:59:35 +0200 [thread overview]
Message-ID: <20261105095935.159650-1-stefan.ghetu@nxp.com> (raw)
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
next reply other threads:[~2026-11-05 10:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 9:59 Stefan Ghetu [this message]
2026-11-05 17:30 ` Frank Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261105095935.159650-1-stefan.ghetu@nxp.com \
--to=stefan.ghetu@nxp.com \
--cc=daniel.baluta@nxp.com \
--cc=han.xu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®