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

This commit is contained in:
Gregory Nutt 2013-10-27 17:22:28 -06:00
parent 1027d9f751
commit d812f25496
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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;