From 09e1d104ba1f86854c1f8c4de1bd6709e396d902 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 18 Nov 2020 12:22:47 +0800 Subject: [PATCH] SHA: fix dma lldesc going out of scope issue DMA process didnt wait for idle before returning. This meant that there was a potential for the dma descriptors which were on the stack to be reclaimed before the DMA operation finished. --- components/mbedtls/port/sha/dma/sha.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/mbedtls/port/sha/dma/sha.c b/components/mbedtls/port/sha/dma/sha.c index 8e21aa5b38..168f34cd46 100644 --- a/components/mbedtls/port/sha/dma/sha.c +++ b/components/mbedtls/port/sha/dma/sha.c @@ -226,7 +226,7 @@ int esp_sha_dma(esp_sha_type sha_type, const void *input, uint32_t ilen, /* Copy to internal buf if buf is in non DMA capable memory */ if (!esp_ptr_dma_ext_capable(buf) && !esp_ptr_dma_capable(buf) && (buf_len != 0)) { - dma_cap_buf = heap_caps_malloc(sizeof(unsigned char) * buf_len, MALLOC_CAP_DMA); + dma_cap_buf = heap_caps_malloc(sizeof(unsigned char) * buf_len, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL); if (dma_cap_buf == NULL) { ESP_LOGE(TAG, "Failed to allocate buf memory"); ret = -1; @@ -301,6 +301,7 @@ static esp_err_t esp_sha_dma_process(esp_sha_type sha_type, const void *input, u sha_hal_hash_dma(sha_type, dma_descr_head, num_blks, is_first_block); + sha_hal_wait_idle(); return ret; }