mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
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.
This commit is contained in:
@@ -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 */
|
/* 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)) {
|
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) {
|
if (dma_cap_buf == NULL) {
|
||||||
ESP_LOGE(TAG, "Failed to allocate buf memory");
|
ESP_LOGE(TAG, "Failed to allocate buf memory");
|
||||||
ret = -1;
|
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_hash_dma(sha_type, dma_descr_head, num_blks, is_first_block);
|
||||||
|
|
||||||
|
sha_hal_wait_idle();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user