Re: [PATCH v2 1/1] mtd: cfi_cmdset_0001: Factor out do_write_buffer_locked() to reduce stack frame

From: Lukas Wunner

Date: Wed Apr 08 2026 - 02:36:09 EST


On Wed, Feb 04, 2026 at 02:25:27AM +0100, Andy Shevchenko wrote:
> Compiler is not happy about used stack frame:
>
> drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer':
> drivers/mtd/chips/cfi_cmdset_0001.c:1887:1: error: the frame size of 1296 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
>
> Fix this by factoring out do_write_buffer_locked().

FWIW, the issue only occurs with CONFIG_KASAN_STACK=y, so an alternative
to refactoring the function is to disable KASAN for this particular file:

diff --git a/drivers/mtd/chips/Makefile b/drivers/mtd/chips/Makefile
index 1f4e84f1cd88..7110eb97bd25 100644
--- a/drivers/mtd/chips/Makefile
+++ b/drivers/mtd/chips/Makefile
@@ -14,3 +14,8 @@ obj-$(CONFIG_MTD_JEDECPROBE) += jedec_probe.o
obj-$(CONFIG_MTD_RAM) += map_ram.o
obj-$(CONFIG_MTD_ROM) += map_rom.o
obj-$(CONFIG_MTD_ABSENT) += map_absent.o
+
+# Avoid exceeding stack frame in do_write_buffer()
+ifeq ($(ARCH),arm)
+KASAN_SANITIZE_cfi_cmdset_0001.o := n
+endif