Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask
@ 2026-08-25  7:33 Pengpeng Hou
  2026-08-29 20:10 ` Radu Rendec
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-08-25  7:33 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Pengpeng Hou, Radu Rendec, Paul Walmsley, Samuel Holland,
	Charles Mirabile, Lucas Zampieri, linux-kernel, linux-riscv

__plic_toggle() builds a 32-bit enable-register mask from the hardware
interrupt number. A valid interrupt whose low five bits are 31 evaluates
1 << 31, which shifts a signed int into its sign bit and is undefined
behavior.

Use BIT(), matching the equivalent mask construction in plic_irq_eoi().

Fixes: 14ff9e54dd14 ("irqchip/sifive-plic: Cache the interrupt enable state")
Assisted-by: Codex:gpt-5
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/irqchip/irq-sifive-plic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index 5b0dac104814..d3d4187b96ab 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -108,6 +108,6 @@ static int plic_irq_set_type(struct irq_data *d, unsigned int type);
 static void __plic_toggle(struct plic_handler *handler, int hwirq, int enable)
 {
 	u32 __iomem *base = handler->enable_base;
-	u32 hwirq_mask = 1 << (hwirq % 32);
+	u32 hwirq_mask = BIT(hwirq % 32);
 	int group = hwirq / 32;
 	u32 value;


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-29 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25  7:33 [PATCH] irqchip/sifive-plic: Avoid signed shift in interrupt enable mask Pengpeng Hou
2026-08-29 20:10 ` Radu Rendec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox