fix(freertos-smp): Stream Buffer task lists must be manipulated in critical sections

Stream buffer task lists (xTaskWaitingToSend and xTaskWaitingToReceive)
are updated without critical sections. These objects are shared objects
and can be updated from an ISR context as well. Hence, these lists must
always be updated in critical sections.
This commit is contained in:
Sudeep Mohanty 2025-10-13 11:07:12 +02:00
parent a1cc3bda48
commit 4ee717950d

View file

@ -947,7 +947,11 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer ); traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer );
( void ) xTaskNotifyWaitIndexed( pxStreamBuffer->uxNotificationIndex, ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait ); ( void ) xTaskNotifyWaitIndexed( pxStreamBuffer->uxNotificationIndex, ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
pxStreamBuffer->xTaskWaitingToSend = NULL; sbENTER_CRITICAL( pxStreamBuffer );
{
pxStreamBuffer->xTaskWaitingToSend = NULL;
}
sbEXIT_CRITICAL( pxStreamBuffer );
} while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE ); } while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE );
} }
else else
@ -1171,7 +1175,11 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
/* Wait for data to be available. */ /* Wait for data to be available. */
traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer ); traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer );
( void ) xTaskNotifyWaitIndexed( pxStreamBuffer->uxNotificationIndex, ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait ); ( void ) xTaskNotifyWaitIndexed( pxStreamBuffer->uxNotificationIndex, ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
pxStreamBuffer->xTaskWaitingToReceive = NULL; sbENTER_CRITICAL( pxStreamBuffer );
{
pxStreamBuffer->xTaskWaitingToReceive = NULL;
}
sbEXIT_CRITICAL( pxStreamBuffer );
/* Recheck the data available after blocking. */ /* Recheck the data available after blocking. */
xBytesAvailable = prvBytesInBuffer( pxStreamBuffer ); xBytesAvailable = prvBytesInBuffer( pxStreamBuffer );