From 498f9aa96a69a65c3c3cfe6435071b39749b634e Mon Sep 17 00:00:00 2001 From: morris Date: Tue, 30 Jun 2026 16:52:26 +0800 Subject: [PATCH] fix(spi_slave): free DMA-private buffers when transaction queue is full spi_slave_queue_trans calls spi_slave_setup_priv_trans to allocate DMA buffers, then tries xQueueSend. If the queue is full the function returns ESP_ERR_TIMEOUT without freeing those buffers, leaking up to 2 * max_transfer_sz per failed call. Call spi_slave_uninstall_priv_trans before returning the timeout. --- components/esp_driver_spi/src/gpspi/spi_slave.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/esp_driver_spi/src/gpspi/spi_slave.c b/components/esp_driver_spi/src/gpspi/spi_slave.c index dde29953408..9beff65602a 100644 --- a/components/esp_driver_spi/src/gpspi/spi_slave.c +++ b/components/esp_driver_spi/src/gpspi/spi_slave.c @@ -460,6 +460,7 @@ esp_err_t SPI_SLAVE_ATTR spi_slave_queue_trans(spi_host_device_t host, const spi r = xQueueSend(spihost[host]->trans_queue, (void *)&priv_trans, ticks_to_wait); if (!r) { + spi_slave_uninstall_priv_trans(host, &priv_trans); return ESP_ERR_TIMEOUT; } esp_intr_enable(spihost[host]->intr);