From 704dfc91857250bab7e92e2d357d326cd72e07f8 Mon Sep 17 00:00:00 2001 From: Christoph Baechler Date: Mon, 15 May 2023 15:02:38 +0200 Subject: [PATCH] esp_ds: ignore releasing mutex if not called from same task --- components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c b/components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c index cbe30e1cf705..023c33671291 100644 --- a/components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c +++ b/components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c @@ -94,8 +94,10 @@ esp_err_t esp_ds_init_data_ctx(esp_ds_data_ctx_t *ds_data) void esp_ds_release_ds_lock(void) { - /* Give back the semaphore (DS lock) */ - xSemaphoreGive(s_ds_lock); + if (xSemaphoreGetMutexHolder(s_ds_lock) == xTaskGetCurrentTaskHandle()) { + /* Give back the semaphore (DS lock) */ + xSemaphoreGive(s_ds_lock); + } } size_t esp_ds_get_keylen(void *ctx)