mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-10-09 23:53:04 -04:00
prvInitThreadKey() ignored pthread_key_create()'s return value, and prvMarkAsFreeRTOSThread() ignored pthread_setspecific()'s return value. If pthread_setspecific() fails, the one-byte thread marker allocated just before it is neither stored in TLS (so prvThreadKeyDestructor() never runs for it, leaking the allocation) nor freed locally -- and the thread is left unmarked, so prvIsFreeRTOSThread() silently misclassifies it as not a FreeRTOS thread. The correctness impact (thread identity) is larger than the one-byte leak itself. Fix: check both return values. On pthread_setspecific() failure, free the marker to avoid the leak, then call prvFatalError() -- the same handling this port already uses for other unexpected pthread call failures (pthread_create(), sigaction()). This function returns void, so there is no way to propagate a failure to the caller; continuing past a failed pthread_setspecific() would leave the thread silently misclassified rather than failing loudly. Same treatment for pthread_key_create(), since a failure there means every later pthread_setspecific()/pthread_getspecific() call on xThreadKey is operating on an invalid key. Fixes #1447 Signed-off-by: Saikumar Mandaji <mandajisaikumar@gmail.com> |
||
|---|---|---|
| .. | ||
| ARC_EM_HS | ||
| ARC_v1 | ||
| ARM_TFM | ||
| ATmega | ||
| Posix | ||
| RISC-V | ||
| RP2040 | ||
| Xtensa_ESP32 | ||