From d812f25496cc190ddd2ad2cafccae20afa2cdb37 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 27 Oct 2013 17:22:28 -0600 Subject: [PATCH] sched/sched_releasetcb.c: Fix an error handling case where a pthread start-up fails early, before the task type has been saved in the TCB. It is safer to use the sched_releasetcb() task type argument instead of relying on the task type in the TCB to be valid. Reported by David Sidrane --- ChangeLog | 4 ++++ sched/sched_releasetcb.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 74df4b44e8..614b9b89fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5896,4 +5896,8 @@ Mikrow STM32F4 board from Ken Pettit (2013-10-27). * arch/arm/src/stm32/stm32_spi.c: DMA-related fixe from Ken Pettit (2013-10-27). + * sched/sched_releasetcb.c: Fix a cornercase: If sched_releasetcb() + is called as part of a failed pthread startup before the flags + field in the TCB has been initialized, then a crash occurs. + Pointed out by David Sidrane (2013-10-27) diff --git a/sched/sched_releasetcb.c b/sched/sched_releasetcb.c index aefc5264de..b0605ef3bd 100644 --- a/sched/sched_releasetcb.c +++ b/sched/sched_releasetcb.c @@ -168,7 +168,7 @@ int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype) */ #ifndef CONFIG_DISABLE_PTHREAD - if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_PTHREAD) + if (ttype != TCB_FLAG_TTYPE_PTHREAD) #endif { FAR struct task_tcb_s *ttcb = (FAR struct task_tcb_s *)tcb;