[PATCH 4/4] mtd: spi-nor: macronix: Describe locking support for MX25L51245G

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Nov 25 10:25:55 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mtd: spi-nor: macronix: overlapping memcpy() in
  mx25l51245_late_init()
--

commit 6981ddae179b4bc4f140785e21d8d0cec9e0f216
Author: Miquel Raynal <miquel.raynal at bootlin.com>

mtd: spi-nor: macronix: Describe locking support for MX25L51245G

This commit adds a late_init fixup for Macronix flash chips matching JEDEC
ID 0xc2201a to read the configuration register and enable block protection
locking if the OTP Top/Bottom bit is cleared.

> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
> index bbc41af148826..87fdbd6c38009 100644
> --- a/drivers/mtd/spi-nor/macronix.c
> +++ b/drivers/mtd/spi-nor/macronix.c

[ ... ]

> @@ -86,6 +87,37 @@ macronix_qpp4b_post_sfdp_fixups(struct spi_nor *nor)
>  	return 0;
>  }
>  
> +static int
> +mx25l51245_late_init(struct spi_nor *nor)
> +{
> +	struct spi_nor_flash_parameter *params = nor->params;
> +
> +	/*
> +	 * Locking is optional, so leave locking disabled if the CR cannot be
> +	 * read (e.g. the controller does not support the 0x15 opcode).
> +	 */
> +	if (spi_nor_read_sr2(nor, nor->bouncebuf))
> +		return 0;

[Severity: Low]
Does passing nor->bouncebuf to spi_nor_read_sr2() cause an overlapping
memcpy()?

spi_nor_read_sr2() calls spi_nor_read_sr_ll(), which uses nor->bouncebuf
for the SPI transfer and then runs memcpy(sr, nor->bouncebuf, len) to copy
the result to the caller's buffer.  Passing a stack u8 variable instead of
nor->bouncebuf avoids calling memcpy() with identical source and
destination pointers.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-macronix-upstreaming-spi-nor-cleanup-v1-0-0d1ab783fd8b@bootlin.com?part=4



More information about the linux-mtd mailing list