drivers: spi: spi_esp32_spim: Fix potential tx_temp leak

If rx_temp allocation fails then tx_temp needs to freed.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
This commit is contained in:
Andriy Gelman 2023-03-12 16:31:05 -04:00 committed by Carles Cufí
parent 0ebc7c2b69
commit 1eff8e76bd

View file

@ -95,6 +95,7 @@ static int IRAM_ATTR spi_esp32_transfer(const struct device *dev)
rx_temp = k_calloc(((ctx->rx_len << 3) + 31) / 8, sizeof(uint8_t));
if (!rx_temp) {
LOG_ERR("Error allocating temp buffer Rx");
k_free(tx_temp);
return -ENOMEM;
}
}