From 22d636b7b0d6006e06b5b3cfddfbf6e2cf69b4b8 Mon Sep 17 00:00:00 2001 From: Michael Balzer Date: Fri, 24 Jul 2020 14:45:48 +0200 Subject: [PATCH] pthread: fix pthread_mutex_destroy() breaking priority inheritance --- components/pthread/pthread.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/pthread/pthread.c b/components/pthread/pthread.c index 2250c4075..ef87e8f22 100644 --- a/components/pthread/pthread.c +++ b/components/pthread/pthread.c @@ -591,7 +591,12 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex) return EBUSY; } + // FreeRTOS mutex must not be deleted while taken (breaks priority inheritance): + vTaskSuspendAll(); + pthread_mutex_unlock(mutex); vSemaphoreDelete(mux->sem); + xTaskResumeAll(); + free(mux); return 0;