[PATCH] spi: spi-zynqmp-gqspi: Initialize padding in partial TX FIFO words
Srikanth Boyapally
srikanth.boyapally at amd.com
Wed Nov 25 09:42:50 PST 2026
From: Liyin Zhang <liyin.zhang.cn at windriver.com>
The TX FIFO takes 32-bit writes. When fewer than four bytes remain,
zynqmp_qspi_filltxfifo() copies only those bytes into the last word.
The remaining bytes can contain stale data from a previous iteration
or be uninitialized if this is the first word.
Initialize the partial word to 0xff before copying the payload. Add
the remaining byte count to count before clearing bytes_to_transfer,
so the final bytes are included in the accounting.
Fixes: 2530b3df4326 ("spi: spi-zynqmp-gqspi: Resolved slab-out-of-bounds bug")
Signed-off-by: Liyin Zhang <liyin.zhang.cn at windriver.com>
Signed-off-by: Srikanth Boyapally <srikanth.boyapally at amd.com>
---
Initialize partial TX FIFO words with 0xff before copying the remaining
payload bytes. Also account for the remaining bytes before clearing
bytes_to_transfer, ensuring correct transfer accounting.
---
drivers/spi/spi-zynqmp-gqspi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index 8e4d940a7785..0411dc6a34ba 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -638,11 +638,12 @@ static void zynqmp_qspi_filltxfifo(struct zynqmp_qspi *xqspi, int size)
xqspi->bytes_to_transfer -= 4;
count += 4;
} else {
+ intermediate = 0xFFFFFFFF;
memcpy(&intermediate, xqspi->txbuf,
xqspi->bytes_to_transfer);
xqspi->txbuf += xqspi->bytes_to_transfer;
- xqspi->bytes_to_transfer = 0;
count += xqspi->bytes_to_transfer;
+ xqspi->bytes_to_transfer = 0;
}
zynqmp_gqspi_write(xqspi, GQSPI_TXD_OFST, intermediate);
}
---
base-commit: d8c1f1ad171d0e5844b6579054fa19ebf6cf7d17
change-id: 20261125-zynqmp_padding-8d1f88eba55f
Best regards,
--
Srikanth Boyapally <srikanth.boyapally at amd.com>
More information about the linux-arm-kernel
mailing list