From 9345cb55534086a179221c38c7dfd143950a828c Mon Sep 17 00:00:00 2001 From: Yang Chung-Fan Date: Tue, 26 May 2020 01:01:21 +0900 Subject: [PATCH] arch: x86: Set the idle task stack to prevent get/set errno on idle task resulting NULL reference --- arch/x86_64/src/common/up_initialize.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/src/common/up_initialize.c b/arch/x86_64/src/common/up_initialize.c index 61e2c3d6f9..3e9dc676fe 100644 --- a/arch/x86_64/src/common/up_initialize.c +++ b/arch/x86_64/src/common/up_initialize.c @@ -43,6 +43,7 @@ #include +#include "sched/sched.h" #include "up_arch.h" #include "up_internal.h" @@ -100,6 +101,12 @@ static void up_calibratedelay(void) void up_initialize(void) { + struct tcb_s *rtcb = this_task(); + + rtcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE; + rtcb->stack_alloc_ptr = + (void *)(g_idle_topstack - CONFIG_IDLETHREAD_STACKSIZE); + /* Initialize global variables */ g_current_regs = NULL; @@ -119,8 +126,8 @@ void up_initialize(void) #endif #ifdef CONFIG_ARCH_DMA - /* Initialize the DMA subsystem if the weak function up_dma_initialize has been - * brought into the build + /* Initialize the DMA subsystem if the weak function up_dma_initialize + * has been brought into the build */ #ifdef CONFIG_HAVE_WEAKFUNCTIONS