diff --git a/sched/semaphore/sem_holder.c b/sched/semaphore/sem_holder.c index b062ef22d6a23..ed2b461661ae6 100644 --- a/sched/semaphore/sem_holder.c +++ b/sched/semaphore/sem_holder.c @@ -319,7 +319,7 @@ static int nxsem_boostholderprio(FAR struct semholder_s *pholder, * because the thread is already running at a sufficient priority. */ - if (rtcb->sched_priority > htcb->sched_priority) + if (rtcb && htcb && rtcb->sched_priority > htcb->sched_priority) { /* Raise the priority of the holder of the semaphore. This * cannot cause a context switch because we have preemption @@ -757,14 +757,13 @@ void nxsem_release_holder(FAR sem_t *sem) return; } } - - /* The current task is not a holder */ - - DEBUGPANIC(); #else pholder = &sem->holder; - DEBUGASSERT(pholder->htcb == rtcb); - nxsem_freeholder(sem, pholder); + if (pholder->htcb) + { + DEBUGASSERT(pholder->htcb == rtcb); + nxsem_freeholder(sem, pholder); + } #endif } }