diff --git a/sched/sched/sched_gettcb.c b/sched/sched/sched_gettcb.c index 9b31aa2404d..776927dd4a8 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