mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-10-09 23:53:04 -04:00
Add ownership check when giving a mutex
Disallow a held mutex from being given by another task, one that did not first take the mutex.
This commit is contained in:
parent
78069a79ea
commit
c028ff4bf5
1 changed files with 14 additions and 0 deletions
14
queue.c
14
queue.c
|
|
@ -966,6 +966,20 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if ( configUSE_MUTEXES == 1 )
|
||||
{
|
||||
/* If the queue is a mutex and is held, only the owner can give it. */
|
||||
if( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) &&
|
||||
( pxQueue->u.xSemaphore.xMutexHolder != NULL ) &&
|
||||
( pxQueue->u.xSemaphore.xMutexHolder != xTaskGetCurrentTaskHandle() ) )
|
||||
{
|
||||
traceRETURN_xQueueGenericSend( pdFAIL );
|
||||
|
||||
return pdFAIL;
|
||||
}
|
||||
}
|
||||
#endif /* configUSE_MUTEXES */
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue