fix(driver_spi): avoid NULL memcpy when private DMA buffer setup fails

Closes https://github.com/espressif/esp-idf/pull/18898
This commit is contained in:
Eric Wang
2026-07-28 13:29:17 -07:00
committed by wanckl
parent d43de5fa7e
commit 87b013936e
2 changed files with 2 additions and 2 deletions

View File

@@ -354,7 +354,7 @@ static void SPI_SLAVE_ISR_ATTR spi_slave_uninstall_priv_trans(spi_host_device_t
if (trans->tx_buffer && (trans->tx_buffer != priv_trans->tx_buffer)) {
free(priv_trans->tx_buffer);
}
if (trans->rx_buffer && (trans->rx_buffer != priv_trans->rx_buffer)) {
if (priv_trans->rx_buffer && (trans->rx_buffer != priv_trans->rx_buffer)) {
memcpy(trans->rx_buffer, priv_trans->rx_buffer, (trans->length + 7) / 8);
free(priv_trans->rx_buffer);
}

View File

@@ -572,7 +572,7 @@ static void s_spi_slave_hd_destroy_priv_trans(spi_host_device_t host, spi_slave_
{
#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
spi_slave_hd_data_t *orig_trans = priv_trans->trans;
if (priv_trans->aligned_buffer != orig_trans->data) {
if (priv_trans->aligned_buffer && priv_trans->aligned_buffer != orig_trans->data) {
if (chan == SPI_SLAVE_CHAN_RX) {
memcpy(orig_trans->data, priv_trans->aligned_buffer, orig_trans->trans_len);
}