This patch adds some missing unlocking from error paths in the OpenACC
attach/detach code, noticed during development of other patches in
this series.

OK?

Julian

ChangeLog

        libgomp/
        * oacc-mem.c (acc_attach_async): Add missing gomp_mutex_unlock on
        error path.
        (goacc_detach_internal): Likewise.
---
 libgomp/oacc-mem.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index 2d4bba78efd..c06b7341cbb 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -887,7 +887,10 @@ acc_attach_async (void **hostaddr, int async)
   n = splay_tree_lookup (&acc_dev->mem_map, &cur_node);
 
   if (n == NULL)
-    gomp_fatal ("struct not mapped for acc_attach");
+    {
+      gomp_mutex_unlock (&acc_dev->lock);
+      gomp_fatal ("struct not mapped for acc_attach");
+    }
 
   gomp_attach_pointer (acc_dev, aq, &acc_dev->mem_map, n, (uintptr_t) hostaddr,
                       0, NULL);
@@ -920,7 +923,10 @@ goacc_detach_internal (void **hostaddr, int async, bool 
finalize)
   n = splay_tree_lookup (&acc_dev->mem_map, &cur_node);
 
   if (n == NULL)
-    gomp_fatal ("struct not mapped for acc_detach");
+    {
+      gomp_mutex_unlock (&acc_dev->lock);
+      gomp_fatal ("struct not mapped for acc_detach");
+    }
 
   gomp_detach_pointer (acc_dev, aq, n, (uintptr_t) hostaddr, finalize, NULL);
 
-- 
2.23.0

Reply via email to