From 1eff8e76bd728b7cab14f044911d9a729eb41db4 Mon Sep 17 00:00:00 2001 From: Andriy Gelman Date: Sun, 12 Mar 2023 16:31:05 -0400 Subject: [PATCH] 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 --- drivers/spi/spi_esp32_spim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi_esp32_spim.c b/drivers/spi/spi_esp32_spim.c index 56f1d648d0..878c021c0e 100644 --- a/drivers/spi/spi_esp32_spim.c +++ b/drivers/spi/spi_esp32_spim.c @@ -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; } }