check fix: Prevent SPI write if tx_buf is or tx_size is 0

To avoid NULL pointer access if tx_buf is NULL but tx_size is not 0
This commit is contained in:
Mikael Ågren 2025-04-09 12:38:04 +02:00
parent c14f8d634a
commit e52b68650f
No known key found for this signature in database
GPG key ID: E02DA3D397792C46

View file

@ -76,7 +76,7 @@ int spi_transfer(uint8_t *cmd, size_t cmd_size, uint8_t *tx_buf, size_t tx_size,
spi_write(cmd, cmd_size);
if (tx_buf != NULL || tx_size != 0) {
if (tx_buf != NULL && tx_size != 0) {
spi_write(tx_buf, tx_size);
}