From dd734d467d6e0961a88bdabbafccede6cccb2156 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 11 Sep 2020 15:43:23 +0200 Subject: score: Fix _Thread_Initialize() Fix an error cleanup path in SMP configurations to avoid a NULL pointer access. Update #3959. --- cpukit/score/src/threadinitialize.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index 4a74426498..4c6d849111 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -60,7 +60,6 @@ bool _Thread_Initialize( } /* Set everything to perform the error case clean up */ - scheduler_index = 0; the_thread->Start.stack_free = config->stack_free; #if defined(RTEMS_SMP) @@ -153,6 +152,7 @@ bool _Thread_Initialize( scheduler_node = NULL; scheduler_node_for_index = the_thread->Scheduler.nodes; scheduler_for_index = &_Scheduler_Table[ 0 ]; + scheduler_index = 0; while ( scheduler_index < _Scheduler_Count ) { Priority_Control priority_for_index; @@ -255,10 +255,6 @@ bool _Thread_Initialize( if ( extension_status ) return true; -#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE -failed: -#endif - #if defined(RTEMS_SMP) while ( scheduler_index > 0 ) { scheduler_node_for_index = (Scheduler_Node *) @@ -277,6 +273,11 @@ failed: &information->Thread_queue_heads.Free, the_thread->Wait.spare_heads ); + +#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE +failed: +#endif + ( *the_thread->Start.stack_free )( the_thread->Start.Initial_stack.area ); return false; } -- cgit v1.2.3