From b145ad82b7a7efde0375a36d081cd2ff41e0b2ab Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Fri, 6 Aug 2021 17:09:09 -0300 Subject: [PATCH] sched: Fix crash on early syslog message with prepended process name Signed-off-by: Gustavo Henrique Nihei --- sched/sched/sched_gettcb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sched/sched/sched_gettcb.c b/sched/sched/sched_gettcb.c index 9b31aa2404..776927dd4a 100644 --- a/sched/sched/sched_gettcb.c +++ b/sched/sched/sched_gettcb.c @@ -56,9 +56,11 @@ FAR struct tcb_s *nxsched_get_tcb(pid_t pid) irqstate_t flags; int hash_ndx; - /* Verify that the PID is within range */ + /* Verify whether g_pidhash hash table has already been allocated and + * whether the PID is within range. + */ - if (pid >= 0) + if (g_pidhash != NULL && pid >= 0) { /* The test and the return setup should be atomic. This still does * not provide proper protection if the recipient of the TCB does not