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

From: Frank Li

Date: Thu Nov 05 2026 - 12:37:16 EST


On Thu, Nov 05, 2026 at 11:59:35AM +0200, Stefan Ghetu wrote:
>
> From: Han Xu <han.xu@xxxxxxx>
>
> 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@xxxxxxx>
> Signed-off-by: Stefan Ghetu <stefan.ghetu@xxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> 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
>
>