]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lists: Properly handle the case we're removing the first elt.
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 26 Feb 2019 17:46:07 +0000 (18:46 +0100)
committerOlivier Houchard <cognet@ci0.org>
Tue, 26 Feb 2019 17:47:59 +0000 (18:47 +0100)
In LIST_DEL_LOCKED(), initialize p2 to NULL, and only attempt to set it back
to its previous value if we had a previous element, and thus p2 is non-NULL.

include/common/mini-clist.h

index fa5df87bb676c02f65cb79288dd5d1890fac4113..08228283a3718671c9d94e5531932bd10a6c5d21 100644 (file)
@@ -226,7 +226,7 @@ struct cond_wordlist {
        do {                                                               \
                while (1) {                                                \
                        struct list *n, *n2;                               \
-                       struct list *p, *p2;                               \
+                       struct list *p, *p2 = NULL;                        \
                        n = HA_ATOMIC_XCHG(&(el)->n, LLIST_BUSY);          \
                        if (n == LLIST_BUSY)                               \
                                continue;                                  \
@@ -248,7 +248,8 @@ struct cond_wordlist {
                        if (n != (el)) {                                   \
                                n2 = HA_ATOMIC_XCHG(&n->p, LLIST_BUSY);    \
                                if (n2 == LLIST_BUSY) {                    \
-                                       p2->n = (el);                      \
+                                       if (p2 != NULL)                    \
+                                               p2->n = (el);              \
                                        (el)->p = p;                       \
                                        (el)->n = n;                       \
                                        __ha_barrier_store();              \