From: Willy Tarreau Date: Sun, 2 Dec 2018 18:22:55 +0000 (+0100) Subject: BUG/MINOR: lb-map: fix unprotected update to server's score X-Git-Tag: v1.9-dev9~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8b476d9521e4355825ae89c24c12ffbbb1791c7;p=thirdparty%2Fhaproxy.git BUG/MINOR: lb-map: fix unprotected update to server's score The loop trying to figure the best server is theorically capable of finishing the loop with best == NULL, causing the HA_ATOMIC_SUB() to fail there. However for this to happen the list should be empty, which is avoided at the beginning of the function. As it is, the function still remains at risk so better address this now. This patch should be backported to 1.8. --- diff --git a/src/lb_map.c b/src/lb_map.c index 2d8faa9ae5..4b992d3a45 100644 --- a/src/lb_map.c +++ b/src/lb_map.c @@ -132,7 +132,8 @@ void recalc_server_map(struct proxy *px) } } px->lbprm.map.srv[o] = best; - HA_ATOMIC_SUB(&best->wscore, tot); + if (best) + HA_ATOMIC_SUB(&best->wscore, tot); } }