[PATCH] mtd: spinand: micron: fix division by zero

Miquel Raynal miquel.raynal at bootlin.com
Mon Dec 30 00:58:16 PST 2024


Hi Micha,

Thanks for the patch, looks important.

Please fix Richard's address in next submission.

On 28/12/2024 at 16:41:06 +01, Micha Ober <git at ober-mail.de> wrote:

> The `ecc_step_size` field ist not set at this point

typo                          ^

> in the call tree, leading to a division by zero.

Definitely needs Fixes: + Cc: stable!

> Read the step size from the mtd device ecc config instead.

s/mtd device//
s/ecc config/ECC configuration/

>
> Signed-off-by: Micha Ober <git at ober-mail.de>
> ---
>  drivers/mtd/nand/spi/micron.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
> index 12601bc4227a..7973996519d3 100644
> --- a/drivers/mtd/nand/spi/micron.c
> +++ b/drivers/mtd/nand/spi/micron.c
> @@ -106,9 +106,10 @@ static int micron_4_ooblayout_free(struct mtd_info *mtd, int section,
>  				   struct mtd_oob_region *region)

What about the exact same situation in the .ecc() hook?

>  {
>  	struct spinand_device *spinand = mtd_to_spinand(mtd);
> +	struct nand_device *nand = mtd_to_nanddev(mtd);
>  
>  	if (section >= spinand->base.memorg.pagesize /
> -			mtd->ecc_step_size)
> +			nanddev_get_ecc_conf(nand)->step_size)
>  		return -ERANGE;
>  
>  	if (section) {



More information about the linux-mtd mailing list