summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-02-06 12:18:38 +0000
committerkib <kib@FreeBSD.org>2015-02-06 12:18:38 +0000
commit98a3318e3710973b79acb6f8733169ea5ea35e4a (patch)
treeeb61ba2d810dae97db319da51b9602191c4a716d
parentad14b24d8d0ec2df5107424880cdbd5bfc7d9a46 (diff)
downloadFreeBSD-src-98a3318e3710973b79acb6f8733169ea5ea35e4a.zip
FreeBSD-src-98a3318e3710973b79acb6f8733169ea5ea35e4a.tar.gz
Fully initialize allocated memory for the new barrier. The
b_destroying member was left uninitialized, which caused spurious EBUSY. PR: 197365 Noted by: Florent Guiliani <fguiliani@verisign.com> Sponsored by: The FreeBSD Foundation MFC after: 1 week
-rw-r--r--lib/libthr/thread/thr_barrier.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/libthr/thread/thr_barrier.c b/lib/libthr/thread/thr_barrier.c
index 86f880e..10b6346 100644
--- a/lib/libthr/thread/thr_barrier.c
+++ b/lib/libthr/thread/thr_barrier.c
@@ -86,16 +86,13 @@ _pthread_barrier_init(pthread_barrier_t *barrier,
if (barrier == NULL || count <= 0)
return (EINVAL);
- bar = malloc(sizeof(struct pthread_barrier));
+ bar = calloc(1, sizeof(struct pthread_barrier));
if (bar == NULL)
return (ENOMEM);
_thr_umutex_init(&bar->b_lock);
_thr_ucond_init(&bar->b_cv);
- bar->b_cycle = 0;
- bar->b_waiters = 0;
bar->b_count = count;
- bar->b_refcount = 0;
*barrier = bar;
return (0);
OpenPOWER on IntegriCloud