]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Hoist common unlock out of if-else control block
authorDev Jain <dev.jain@arm.com>
Mon, 15 Sep 2025 11:43:29 +0000 (17:13 +0530)
committerDJ Delorie <dj@redhat.com>
Thu, 18 Sep 2025 19:50:15 +0000 (15:50 -0400)
We currently unlock the arena mutex in arena_get_retry() unconditionally.
Therefore, hoist out the unlock from the if-else control block.

Signed-off-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
malloc/arena.c

index 4cc9881d82e16fe5b4a43702a415b3d2c1a72cf7..4cd79d7244bf62d2a97af2b09241a7d23e73a82a 100644 (file)
@@ -861,15 +861,14 @@ static mstate
 arena_get_retry (mstate ar_ptr, size_t bytes)
 {
   LIBC_PROBE (memory_arena_retry, 2, bytes, ar_ptr);
+  __libc_lock_unlock (ar_ptr->mutex);
   if (ar_ptr != &main_arena)
     {
-      __libc_lock_unlock (ar_ptr->mutex);
       ar_ptr = &main_arena;
       __libc_lock_lock (ar_ptr->mutex);
     }
   else
     {
-      __libc_lock_unlock (ar_ptr->mutex);
       ar_ptr = arena_get2 (bytes, ar_ptr);
     }