Skip to contentSkip to conversation

genirq: Avoid signed shift when probing IRQ 31

PATCH New Avi Weiss 1 participant 1 message Nov 1 IRQ

lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 genirq: Avoid signed shift when probing IRQ 31

probe_irq_on() uses a signed int literal to set bits in an unsigned long mask. For IRQ 31, the shift results in undefined behavior and can set bits 32-63 on 64-bit systems.

Use UL suffix - promote to unsigned long so we set only the intended IRQ bit. Current in-tree callers do not appear to use the affected upper bits, but better to clean it up now for future correctness and safety.

---
 kernel/irq/autoprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/irq/autoprobe.c +1 -1
index d0af8a8b3ae67..a46376373b3ea 100644
@@ -88,7 +88,7 @@ unsigned long probe_irq_on(void)
 				desc->istate &= ~IRQS_AUTODETECT;
 				irq_shutdown_and_deactivate(desc);
 			} else if (i < 32) {
-				mask |= 1 << i;
+				mask |= 1UL << i;
 			}
 		}
 	}
Signature · 1 line
2.43.0