diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index e7183d589b67eb400d05d56206b254c6c96ca6d7..e8a6fbf22f7d0e2205d47283860ec4bca3e9202e 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-20  Jakub Jelinek  <jakub@redhat.com>
+
+	PR libgomp/40174
+	* team.c (gomp_thread_start): Destroy thr->release semaphore.
+	(gomp_free_pool_helper): Likewise.
+
 2009-04-20  Vasilis Liaskovitis  <vliaskov@gmail.com>
 	    Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/libgomp/team.c b/libgomp/team.c
index 4110e3f22b24d980b1b4bf91f24f855f6bbe84c9..44ffd56095ffb425da26579a4696775db67a7e0a 100644
--- a/libgomp/team.c
+++ b/libgomp/team.c
@@ -125,6 +125,7 @@ gomp_thread_start (void *xdata)
       while (local_fn);
     }
 
+  gomp_sem_destroy (&thr->release);
   return NULL;
 }
 
@@ -201,6 +202,7 @@ gomp_free_pool_helper (void *thread_pool)
   struct gomp_thread_pool *pool
     = (struct gomp_thread_pool *) thread_pool;
   gomp_barrier_wait_last (&pool->threads_dock);
+  gomp_sem_destroy (&gomp_thread ()->release);
   pthread_exit (NULL);
 }