Re: [PATCH v2] mtd: spi-nor: sfdp: reduce stack usage in spi_nor_parse_sfdp()
From: Miquel Raynal
Date: Thu Oct 15 2026 - 07:52:25 EST
On 15/10/2026 at 13:31:52 +02, Michael Walle <mwalle@xxxxxxxxxx> 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@xxxxxxxx>
> Suggested-by: David Laight <david.laight.linux@xxxxxxxxx>
> Fixes: d20029474a76 ("mtd: spi-nor: push the rollback mechanism into the sfdp module")
> Signed-off-by: Michael Walle <mwalle@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxxx>