The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=aa15df4597053c0e95a15b2a7036296999cd562a

commit aa15df4597053c0e95a15b2a7036296999cd562a
Author:     Dag-Erling Smørgrav <[email protected]>
AuthorDate: 2026-03-16 20:36:56 +0000
Commit:     Dag-Erling Smørgrav <[email protected]>
CommitDate: 2026-03-16 20:36:56 +0000

    queue.h: Reorder STAILQ_INSERT_TAIL
    
    The current implementation briefly violates the tail invariant.  This
    is not usually an issue, but if an insert is in flight when a panic
    occurs, we may then trip the invariant while dumping core.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Sponsored by:   NetApp, Inc.
    Reviewed by:    obiwac, olce, jhb
    Differential Revision:  https://reviews.freebsd.org/D55819
---
 sys/sys/queue.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index aa6453889e6b..e2603bc664c3 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -499,9 +499,10 @@ struct {                                                   
        \
 
 #define STAILQ_INSERT_TAIL(head, elm, field) do {                      \
        QMD_STAILQ_CHECK_TAIL(head);                                    \
+       __typeof__((head)->stqh_last) prevlast = (head)->stqh_last;     \
        STAILQ_NEXT((elm), field) = NULL;                               \
-       *(head)->stqh_last = (elm);                                     \
        (head)->stqh_last = &STAILQ_NEXT((elm), field);                 \
+       *prevlast = (elm);                                              \
 } while (0)
 
 #define STAILQ_LAST(head, type, field)                                 \

Reply via email to