Skip to content

Commit d73f0f4

Browse files
Radhey Shyam PandeyKAGA-KOKO
authored andcommitted
irqchip/xilinx: Fix shift out of bounds
The device tree property 'xlnx,kind-of-intr' is sanity checked that the bitmask contains only set bits which are in the range of the number of interrupts supported by the controller. The check is done by shifting the mask right by the number of supported interrupts and checking the result for zero. The data type of the mask is u32 and the number of supported interrupts is up to 32. In case of 32 interrupts the shift is out of bounds, resulting in a mismatch warning. The out of bounds condition is also reported by UBSAN: UBSAN: shift-out-of-bounds in irq-xilinx-intc.c:332:22 shift exponent 32 is too large for 32-bit type 'unsigned int' Fix it by promoting the mask to u64 for the test. Fixes: d50466c ("microblaze: intc: Refactor DT sanity check") Signed-off-by: Radhey Shyam Pandey <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/[email protected]
1 parent edbbaae commit d73f0f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/irqchip/irq-xilinx-intc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static int __init xilinx_intc_of_init(struct device_node *intc,
189189
irqc->intr_mask = 0;
190190
}
191191

192-
if (irqc->intr_mask >> irqc->nr_irq)
192+
if ((u64)irqc->intr_mask >> irqc->nr_irq)
193193
pr_warn("irq-xilinx: mismatch in kind-of-intr param\n");
194194

195195
pr_info("irq-xilinx: %pOF: num_irq=%d, edge=0x%x\n",

0 commit comments

Comments
 (0)