mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(bt/osi): add NULL check in osi_mutex_free and osi_sem_free (IDFGH-16853)
(cherry picked from commit 8630040602)
Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
committed by
zhanghaipeng
parent
f1c9541975
commit
1bfb20d677
@@ -65,10 +65,15 @@ void osi_mutex_unlock(osi_mutex_t *mutex)
|
|||||||
xSemaphoreGive(*mutex);
|
xSemaphoreGive(*mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete a semaphore
|
/** Delete a mutex
|
||||||
* @param mutex the mutex to delete */
|
* @param mutex the mutex to delete
|
||||||
|
* Note: Safe to call with NULL or uninitialized mutex (IDFGH-16853)
|
||||||
|
*/
|
||||||
void osi_mutex_free(osi_mutex_t *mutex)
|
void osi_mutex_free(osi_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
|
if (mutex == NULL || *mutex == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
vSemaphoreDelete(*mutex);
|
vSemaphoreDelete(*mutex);
|
||||||
*mutex = NULL;
|
*mutex = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,9 +69,15 @@ osi_sem_take(osi_sem_t *sem, uint32_t timeout)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deallocates a semaphore
|
/** Deallocates a semaphore
|
||||||
|
* @param sem the semaphore to delete
|
||||||
|
* Note: Safe to call with NULL or uninitialized semaphore (IDFGH-16853)
|
||||||
|
*/
|
||||||
void osi_sem_free(osi_sem_t *sem)
|
void osi_sem_free(osi_sem_t *sem)
|
||||||
{
|
{
|
||||||
|
if (sem == NULL || *sem == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
vSemaphoreDelete(*sem);
|
vSemaphoreDelete(*sem);
|
||||||
*sem = NULL;
|
*sem = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user