Files
Kees Cook 2a490521d7 spi: axi-spi-engine: Start the program length at zero
spi_engine_optimize_message() allocates the program with kzalloc_flex(),
which sets the __counted_by() counter "length" to the allocated size when
the compiler supports __builtin_counted_by_ref(). The program is then
filled by spi_engine_program_add_cmd(), which increments "length" and
stores at length - 1, expecting it to start at zero as it did when the
program came from kzalloc().

Reset "length" after the allocation, since it is a "usage" counter, not
a "total allocation" counter.

Build tested ARCH=x86_64 defconfig with CONFIG_SPI_AXI_SPI_ENGINE=m and
W=1, with GCC 16.2.0.

Reported-by: Dennis Gilmore <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Fixes: 69050f8d6d ("treewide: Replace kmalloc with kmalloc_obj for non-scalar types")
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
Reviewed-by: David Lechner <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>
2026-11-13 16:26:07 +00:00
..
…
2026-08-07 18:57:43 +01:00
2026-09-07 18:18:53 +01:00
2026-08-07 18:57:49 +01:00
2026-10-13 18:37:23 +01:00
2026-10-12 23:27:00 +01:00
2026-10-19 18:00:23 +01:00
2026-09-07 18:18:53 +01:00
2026-08-07 18:58:04 +01:00
…
2026-07-29 12:59:46 +01:00
2026-08-07 18:58:18 +01:00
2026-09-07 18:18:53 +01:00
2026-10-19 18:00:23 +01:00
2026-09-07 18:18:53 +01:00