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 <sudarsansamy2002@gmail.com>
This commit is contained in:
sudarsan N 2025-06-18 17:55:56 +05:30 committed by Daniel DeGrasse
parent 7a80ef3e8b
commit 6efb1b40ce

View File

@ -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;
}