]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp: Release device lock on cbuf error path
authorJulian Brown <julian@codesourcery.com>
Fri, 24 Sep 2021 11:18:40 +0000 (04:18 -0700)
committerJulian Brown <julian@codesourcery.com>
Tue, 12 Oct 2021 13:50:26 +0000 (06:50 -0700)
This patch releases the device lock on a sanity-checking error path in
transfer combining (cbuf) handling in libgomp:target.c.  This shouldn't
happen when handling well-formed mapping clauses, but erroneous clauses
can currently cause a hang if the condition triggers.

2021-12-10  Julian Brown  <julian@codesourcery.com>

libgomp/
* target.c (gomp_copy_host2dev): Release device lock on cbuf
error path.

libgomp/target.c

index 67fcf41cc2e6e68116f8db0093d9c0df7de63e8d..196dba4f08cc1a01b2a8522070bf1229e426b48d 100644 (file)
@@ -385,7 +385,10 @@ gomp_copy_host2dev (struct gomp_device_descr *devicep,
              else if (cbuf->chunks[middle].start <= doff)
                {
                  if (doff + sz > cbuf->chunks[middle].end)
-                   gomp_fatal ("internal libgomp cbuf error");
+                   {
+                     gomp_mutex_unlock (&devicep->lock);
+                     gomp_fatal ("internal libgomp cbuf error");
+                   }
                  memcpy ((char *) cbuf->buf + (doff - cbuf->chunks[0].start),
                          h, sz);
                  return;