5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hongjian Dai [ Upstream commit 2066970324a1439e5a2e08c4599098367f8f82cc ] pic32_sqi_one_transfer() silently stopped programming buffer descriptors when ring_desc_get() returned NULL and still returned success. The caller then marked the last programmed descriptor as the end of the list and started the DMA engine, so the hardware transferred only a prefix of the requested data while the message completed with status 0. The ring holds PESQI_BD_COUNT (256) descriptors of at most PESQI_BD_BUF_LEN_MAX (256) bytes each, so messages larger than 64 KiB (or with enough SG entries) can exhaust it. Since the driver sets no max_message_size/max_transfer_size, the SPI core does not prevent this. Return -ENOMEM instead, and set msg->status so the failure reaches the caller rather than being silently truncated. Fixes: 3270ac230f66 ("spi: pic32-sqi: add SPI driver for PIC32 SQI controller.") Signed-off-by: Hongjian Dai Link: https://patch.msgid.link/F5276982A630220B+20261017075545.95854-1-daihongjian@kylinsec.com.cn Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-pic32-sqi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-pic32-sqi.c b/drivers/spi/spi-pic32-sqi.c index 86ad17597f5fd..0b32714633e9a 100644 --- a/drivers/spi/spi-pic32-sqi.c +++ b/drivers/spi/spi-pic32-sqi.c @@ -297,7 +297,7 @@ static int pic32_sqi_one_transfer(struct pic32_sqi *sqi, /* get ring descriptor */ rdesc = ring_desc_get(sqi); if (!rdesc) - break; + return -ENOMEM; bd = rdesc->bd; @@ -387,6 +387,7 @@ static int pic32_sqi_one_message(struct spi_master *master, ret = pic32_sqi_one_transfer(sqi, msg, xfer); if (ret) { dev_err(&spi->dev, "xfer %p err\n", xfer); + msg->status = ret; goto xfer_out; } } -- 2.53.0