mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Add assert check for NULL TCB handle (#1177)
Co-authored-by: ActoryOu <jay2002824@gmail.com>
This commit is contained in:
parent
a081ba8b9c
commit
7d76dceaad
37
tasks.c
37
tasks.c
|
@ -2203,6 +2203,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* If null is passed in here then it is the calling task that is
|
/* If null is passed in here then it is the calling task that is
|
||||||
* being deleted. */
|
* being deleted. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTaskToDelete );
|
pxTCB = prvGetTCBFromHandle( xTaskToDelete );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
/* Remove task from the ready/delayed list. */
|
/* Remove task from the ready/delayed list. */
|
||||||
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
|
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
|
||||||
|
@ -2495,7 +2496,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
|
|
||||||
traceENTER_eTaskGetState( xTask );
|
traceENTER_eTaskGetState( xTask );
|
||||||
|
|
||||||
configASSERT( pxTCB );
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES == 1 )
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
if( pxTCB == pxCurrentTCB )
|
if( pxTCB == pxCurrentTCB )
|
||||||
|
@ -2628,6 +2629,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* If null is passed in here then it is the priority of the task
|
/* If null is passed in here then it is the priority of the task
|
||||||
* that called uxTaskPriorityGet() that is being queried. */
|
* that called uxTaskPriorityGet() that is being queried. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
uxReturn = pxTCB->uxPriority;
|
uxReturn = pxTCB->uxPriority;
|
||||||
}
|
}
|
||||||
portBASE_TYPE_EXIT_CRITICAL();
|
portBASE_TYPE_EXIT_CRITICAL();
|
||||||
|
@ -2676,6 +2679,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* If null is passed in here then it is the priority of the calling
|
/* If null is passed in here then it is the priority of the calling
|
||||||
* task that is being queried. */
|
* task that is being queried. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
uxReturn = pxTCB->uxPriority;
|
uxReturn = pxTCB->uxPriority;
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );
|
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );
|
||||||
|
@ -2702,6 +2707,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* If null is passed in here then it is the base priority of the task
|
/* If null is passed in here then it is the base priority of the task
|
||||||
* that called uxTaskBasePriorityGet() that is being queried. */
|
* that called uxTaskBasePriorityGet() that is being queried. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
uxReturn = pxTCB->uxBasePriority;
|
uxReturn = pxTCB->uxBasePriority;
|
||||||
}
|
}
|
||||||
portBASE_TYPE_EXIT_CRITICAL();
|
portBASE_TYPE_EXIT_CRITICAL();
|
||||||
|
@ -2750,6 +2757,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* If null is passed in here then it is the base priority of the calling
|
/* If null is passed in here then it is the base priority of the calling
|
||||||
* task that is being queried. */
|
* task that is being queried. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
uxReturn = pxTCB->uxBasePriority;
|
uxReturn = pxTCB->uxBasePriority;
|
||||||
}
|
}
|
||||||
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );
|
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus );
|
||||||
|
@ -2794,6 +2803,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* If null is passed in here then it is the priority of the calling
|
/* If null is passed in here then it is the priority of the calling
|
||||||
* task that is being changed. */
|
* task that is being changed. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
traceTASK_PRIORITY_SET( pxTCB, uxNewPriority );
|
traceTASK_PRIORITY_SET( pxTCB, uxNewPriority );
|
||||||
|
|
||||||
|
@ -2988,6 +2998,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
pxTCB->uxCoreAffinityMask = uxCoreAffinityMask;
|
pxTCB->uxCoreAffinityMask = uxCoreAffinityMask;
|
||||||
|
|
||||||
|
@ -3043,6 +3054,8 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
portBASE_TYPE_ENTER_CRITICAL();
|
portBASE_TYPE_ENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
uxCoreAffinityMask = pxTCB->uxCoreAffinityMask;
|
uxCoreAffinityMask = pxTCB->uxCoreAffinityMask;
|
||||||
}
|
}
|
||||||
portBASE_TYPE_EXIT_CRITICAL();
|
portBASE_TYPE_EXIT_CRITICAL();
|
||||||
|
@ -3066,6 +3079,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
pxTCB->xPreemptionDisable = pdTRUE;
|
pxTCB->xPreemptionDisable = pdTRUE;
|
||||||
}
|
}
|
||||||
|
@ -3089,6 +3103,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
pxTCB->xPreemptionDisable = pdFALSE;
|
pxTCB->xPreemptionDisable = pdFALSE;
|
||||||
|
|
||||||
|
@ -3122,6 +3137,7 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
|
||||||
/* If null is passed in here then it is the running task that is
|
/* If null is passed in here then it is the running task that is
|
||||||
* being suspended. */
|
* being suspended. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTaskToSuspend );
|
pxTCB = prvGetTCBFromHandle( xTaskToSuspend );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
traceTASK_SUSPEND( pxTCB );
|
traceTASK_SUSPEND( pxTCB );
|
||||||
|
|
||||||
|
@ -4194,7 +4210,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery )
|
||||||
/* If null is passed in here then the name of the calling task is being
|
/* If null is passed in here then the name of the calling task is being
|
||||||
* queried. */
|
* queried. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTaskToQuery );
|
pxTCB = prvGetTCBFromHandle( xTaskToQuery );
|
||||||
configASSERT( pxTCB );
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
traceRETURN_pcTaskGetName( &( pxTCB->pcTaskName[ 0 ] ) );
|
traceRETURN_pcTaskGetName( &( pxTCB->pcTaskName[ 0 ] ) );
|
||||||
|
|
||||||
|
@ -4357,6 +4373,7 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery )
|
||||||
configASSERT( ppxTaskBuffer != NULL );
|
configASSERT( ppxTaskBuffer != NULL );
|
||||||
|
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE == 1 )
|
#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE == 1 )
|
||||||
{
|
{
|
||||||
|
@ -4596,7 +4613,7 @@ BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp )
|
||||||
|
|
||||||
traceENTER_xTaskAbortDelay( xTask );
|
traceENTER_xTaskAbortDelay( xTask );
|
||||||
|
|
||||||
configASSERT( pxTCB );
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
vTaskSuspendAll();
|
vTaskSuspendAll();
|
||||||
{
|
{
|
||||||
|
@ -4978,6 +4995,7 @@ BaseType_t xTaskIncrementTick( void )
|
||||||
|
|
||||||
/* If xTask is NULL then set the calling task's hook. */
|
/* If xTask is NULL then set the calling task's hook. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
/* Save the hook function in the TCB. A critical section is required as
|
/* Save the hook function in the TCB. A critical section is required as
|
||||||
* the value can be accessed from an interrupt. */
|
* the value can be accessed from an interrupt. */
|
||||||
|
@ -5007,6 +5025,7 @@ BaseType_t xTaskIncrementTick( void )
|
||||||
|
|
||||||
/* If xTask is NULL then set the calling task's hook. */
|
/* If xTask is NULL then set the calling task's hook. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
/* Save the hook function in the TCB. A critical section is required as
|
/* Save the hook function in the TCB. A critical section is required as
|
||||||
* the value can be accessed from an interrupt. */
|
* the value can be accessed from an interrupt. */
|
||||||
|
@ -5984,6 +6003,8 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
|
||||||
( xIndex < ( BaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS ) )
|
( xIndex < ( BaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS ) )
|
||||||
{
|
{
|
||||||
pxTCB = prvGetTCBFromHandle( xTaskToQuery );
|
pxTCB = prvGetTCBFromHandle( xTaskToQuery );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ];
|
pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -6011,6 +6032,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
|
||||||
/* If null is passed in here then we are modifying the MPU settings of
|
/* If null is passed in here then we are modifying the MPU settings of
|
||||||
* the calling task. */
|
* the calling task. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTaskToModify );
|
pxTCB = prvGetTCBFromHandle( xTaskToModify );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), pxRegions, NULL, 0 );
|
vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), pxRegions, NULL, 0 );
|
||||||
|
|
||||||
|
@ -6141,6 +6163,7 @@ static void prvCheckTasksWaitingTermination( void )
|
||||||
|
|
||||||
/* xTask is NULL then get the state of the calling task. */
|
/* xTask is NULL then get the state of the calling task. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
pxTaskStatus->xHandle = pxTCB;
|
pxTaskStatus->xHandle = pxTCB;
|
||||||
pxTaskStatus->pcTaskName = ( const char * ) &( pxTCB->pcTaskName[ 0 ] );
|
pxTaskStatus->pcTaskName = ( const char * ) &( pxTCB->pcTaskName[ 0 ] );
|
||||||
|
@ -6357,6 +6380,7 @@ static void prvCheckTasksWaitingTermination( void )
|
||||||
* type. */
|
* type. */
|
||||||
|
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
#if portSTACK_GROWTH < 0
|
#if portSTACK_GROWTH < 0
|
||||||
{
|
{
|
||||||
|
@ -6389,6 +6413,7 @@ static void prvCheckTasksWaitingTermination( void )
|
||||||
traceENTER_uxTaskGetStackHighWaterMark( xTask );
|
traceENTER_uxTaskGetStackHighWaterMark( xTask );
|
||||||
|
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
#if portSTACK_GROWTH < 0
|
#if portSTACK_GROWTH < 0
|
||||||
{
|
{
|
||||||
|
@ -8288,6 +8313,7 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
/* If null is passed in here then it is the calling task that is having
|
/* If null is passed in here then it is the calling task that is having
|
||||||
* its notification state cleared. */
|
* its notification state cleared. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
|
@ -8327,6 +8353,7 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
/* If null is passed in here then it is the calling task that is having
|
/* If null is passed in here then it is the calling task that is having
|
||||||
* its notification state cleared. */
|
* its notification state cleared. */
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
|
@ -8354,6 +8381,7 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
traceENTER_ulTaskGetRunTimeCounter( xTask );
|
traceENTER_ulTaskGetRunTimeCounter( xTask );
|
||||||
|
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
traceRETURN_ulTaskGetRunTimeCounter( pxTCB->ulRunTimeCounter );
|
traceRETURN_ulTaskGetRunTimeCounter( pxTCB->ulRunTimeCounter );
|
||||||
|
|
||||||
|
@ -8381,6 +8409,8 @@ TickType_t uxTaskResetEventItemValue( void )
|
||||||
if( ulTotalTime > ( configRUN_TIME_COUNTER_TYPE ) 0 )
|
if( ulTotalTime > ( configRUN_TIME_COUNTER_TYPE ) 0 )
|
||||||
{
|
{
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
ulReturn = pxTCB->ulRunTimeCounter / ulTotalTime;
|
ulReturn = pxTCB->ulRunTimeCounter / ulTotalTime;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -8584,6 +8614,7 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
|
||||||
traceENTER_xTaskGetMPUSettings( xTask );
|
traceENTER_xTaskGetMPUSettings( xTask );
|
||||||
|
|
||||||
pxTCB = prvGetTCBFromHandle( xTask );
|
pxTCB = prvGetTCBFromHandle( xTask );
|
||||||
|
configASSERT( pxTCB != NULL );
|
||||||
|
|
||||||
traceRETURN_xTaskGetMPUSettings( &( pxTCB->xMPUSettings ) );
|
traceRETURN_xTaskGetMPUSettings( &( pxTCB->xMPUSettings ) );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue