[PATCH 07/10] spi: cadence-xspi: Zero the tail word in m_iowriteq()

From: Lee Jones

Date: Thu Nov 19 2026 - 04:19:24 EST


m_iowriteq() writes data which is not 8-byte aligned, as well as any
trailing bytes which do not make up a full 64-bit word, through a stack
temporary. Only min(len, 8) bytes are copied into that temporary
before all 8 bytes are written to the SDMA FIFO with writeq(), so when
the remaining length is not a multiple of 8, up to 7 bytes of
uninitialised kernel stack are written to the FIFO.

Zero-initialise the temporary so that the padding bytes are always
zero.

Fixes: 75128e2a14a9 ("spi: cadence: Add Marvell SDMA operations")
Closes: https://sashiko.dev/#/bug/linux-a7158f26-3bb5-4ac2-913d-482e746b5a02
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/spi/spi-cadence-xspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 72852849ba27..c4fcbf5ae091 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1088,7 +1088,7 @@ static void m_iowriteq(void __iomem *addr, const void *buf, int len)
}

while (len) {
- u64 tmp_buf;
+ u64 tmp_buf = 0;

memcpy(&tmp_buf, buf, min(len, 8));
writeq(tmp_buf, addr);
--
2.56.1.708.g77570a6a1d-goog