Skip to content

Commit 6efb1b4

Browse files
sudarsan-22danieldegrasse
authored andcommitted
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>
1 parent 7a80ef3 commit 6efb1b4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/spi/spi_rtio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ int spi_rtio_copy(struct rtio *r,
192192
rx_len = rx_bufs->buffers[rx].len;
193193
} else {
194194
rx_buf = NULL;
195-
rx_len = tx_bufs->buffers[tx].len;
195+
rx_len = (tx_bufs != NULL && tx < tx_count) ? tx_bufs->buffers[tx].len : 0;
196196
}
197197

198198

0 commit comments

Comments
 (0)