From ebf4abca1410242804480663a5ae7d4f00c78fed 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 86e15b6950..7baa0415da 100644 --- a/components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c +++ b/components/mbedtls/port/esp_ds/esp_rsa_sign_alt.c @@ -91,8 +91,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)