diff --git a/libs/libc/pthread/pthread_barrierdestroy.c b/libs/libc/pthread/pthread_barrierdestroy.c index 03bd2d9900..11625f5c4c 100644 --- a/libs/libc/pthread/pthread_barrierdestroy.c +++ b/libs/libc/pthread/pthread_barrierdestroy.c @@ -61,6 +61,7 @@ int pthread_barrier_destroy(FAR pthread_barrier_t *barrier) { + int semcount; int ret = OK; if (!barrier) @@ -69,6 +70,17 @@ int pthread_barrier_destroy(FAR pthread_barrier_t *barrier) } else { + ret = sem_getvalue(&barrier->sem, &semcount); + if (ret != OK) + { + return ret; + } + + if (semcount < 0) + { + return EBUSY; + } + sem_destroy(&barrier->sem); barrier->count = 0; }