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

Frank Li Frank.li at oss.nxp.com
Thu Nov 5 09:30:34 PST 2026


On Thu, Nov 05, 2026 at 11:59:35AM +0200, Stefan Ghetu wrote:
>
> 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>
> ---

Reviewed-by: Frank Li <Frank.Li 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