From: Nathan Chancellor Date: Mon, 12 May 2025 22:16:55 +0000 (+0200) Subject: genirq: Ensure flags in lock guard is consistently initialized X-Git-Tag: v6.16-rc1~189^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5fcb6898202858ae8425bf0cd9cb5704735bd02;p=thirdparty%2Flinux.git genirq: Ensure flags in lock guard is consistently initialized After the conversion to locking guards within the interrupt core code, several builds with clang show the "Interrupts were enabled early" WARN() in start_kernel() on boot. In class_irqdesc_lock_constructor(), _t.flags is initialized via __irq_get_desc_lock() within the _t initializer list. However, the C11 standard 6.7.9.23 states that the evaluation of the initialization list expressions are indeterminately sequenced relative to one another, meaning _t.flags could be initialized by __irq_get_desc_lock() then be initialized to zero due to flags being absent from the initializer list. To ensure _t.flags is consistently initialized, move the call to __irq_get_desc_lock() and the assignment of its result to _t.lock out of the designated initializer. Fixes: 0f70a49f3fa3 ("genirq: Provide conditional lock guards") Signed-off-by: Nathan Chancellor Signed-off-by: Thomas Gleixner Reviewed-by: Jiri Slaby Link: https://lore.kernel.org/all/20250513-irq-guards-fix-flags-init-v1-1-1dca3f5992d6@kernel.org --- diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index bd2db6ebb98ee..476a20fd9bfce 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -176,10 +176,10 @@ __DEFINE_UNLOCK_GUARD(irqdesc_lock, struct irq_desc, static inline class_irqdesc_lock_t class_irqdesc_lock_constructor(unsigned int irq, bool bus, unsigned int check) { - class_irqdesc_lock_t _t = { - .bus = bus, - .lock = __irq_get_desc_lock(irq, &_t.flags, bus, check), - }; + class_irqdesc_lock_t _t = { .bus = bus, }; + + _t.lock = __irq_get_desc_lock(irq, &_t.flags, bus, check); + return _t; }