From 6efb1b40ce34e15efda60dc2914388a17e82f94a Mon Sep 17 00:00:00 2001 From: sudarsan N Date: Wed, 18 Jun 2025 17:55:56 +0530 Subject: [PATCH] drivers: spi_rtio: Fix potential null pointer dereference Avoid accessing tx_bufs or rx_bufs when they are NULL by adding proper conditional checks before dereferencing. This addresses Coverity issue CID 516225 (CWE-476). Signed-off-by: sudarsan N --- drivers/spi/spi_rtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi_rtio.c b/drivers/spi/spi_rtio.c index 1a051ba9d7d..1b6a83ad01b 100644 --- a/drivers/spi/spi_rtio.c +++ b/drivers/spi/spi_rtio.c @@ -192,7 +192,7 @@ int spi_rtio_copy(struct rtio *r, rx_len = rx_bufs->buffers[rx].len; } else { rx_buf = NULL; - rx_len = tx_bufs->buffers[tx].len; + rx_len = (tx_bufs != NULL && tx < tx_count) ? tx_bufs->buffers[tx].len : 0; }