[PATCH v2] mtd: spi-nor: sfdp: reduce stack usage in spi_nor_parse_sfdp()

Miquel Raynal miquel.raynal at bootlin.com
Thu Oct 15 04:48:42 PDT 2026


On 15/10/2026 at 13:31:52 +02, Michael Walle <mwalle at kernel.org> wrote:

> Two large spi_nor_flash_parameter structures on a function stack
> are really too much, and this can exceed an otherwise reasonable
> frame limit:
>
> drivers/mtd/spi-nor/sfdp.c: In function 'spi_nor_parse_sfdp':
> drivers/mtd/spi-nor/sfdp.c:1717:1: error: the frame size of 1600 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
>
> Allocate both rollback copies on the heap and use structure copies
> for type safety.
>
> Suggested-by: Arnd Bergmann <arnd at arndb.de>
> Suggested-by: David Laight <david.laight.linux at gmail.com>
> Fixes: d20029474a76 ("mtd: spi-nor: push the rollback mechanism into the sfdp module")
> Signed-off-by: Michael Walle <mwalle at kernel.org>
> ---
> v2:
>  - don't use the cleanup helpers to not mix them with gotos as
>    suggested by Miquel. I didn't carry your Rb over because there
>    is quite a bit more code change.

Would have been fine.

Reviewed-by: Miquel Raynal <miquel.raynal at bootlin.com>



More information about the linux-mtd mailing list