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