From: Olivier Houchard Date: Mon, 1 Jun 2026 13:52:21 +0000 (+0200) Subject: BUG/MEDIUM: leastconn: Unlock the write lock on allocation failure X-Git-Tag: v3.4.0~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0aa9f01f113c2b61794107ee1b79e28a59bd896;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: leastconn: Unlock the write lock on allocation failure When we fail to allocate a new tree element, we're still holding the write lock, so we should do an write unlock, not a read unlock, or the lock will get corrupted and most likely this will end in a deadlock. This should be backported up to 3.2. --- diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index 6657d4c1e..6c1cd13e0 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -437,7 +437,7 @@ static void fwlc_srv_reposition(struct server *s) tree_elt = fwlc_alloc_tree_elt(s->proxy, allocated_elt); if (tree_elt == NULL) { /* We failed to allocate memory, just try again later */ - HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock); + HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock); _HA_ATOMIC_STORE(&s->lb_lock, 0); if (s->requeue_tasklet) tasklet_wakeup(s->requeue_tasklet);