Message ID | 1723101895-3470952-1-git-send-email-radhey.shyam.pandey@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | irqchip/xilinx: fix shift out of bounds warning | expand |
On Thu, Aug 08 2024 at 12:54, Radhey Shyam Pandey wrote: irqchip/xilinx: fix shift out of bounds warning Please start the sentence after the colon with an upper case letter. Also you can't fix a out of bound warning. You can fix the code which causes the warning > In case num_irq is 32 there is shift out of bound and result in false What is num_irq? This is text and not subject to random acronyms. https://www.kernel.org/doc/html/latest/process/maintainer-tip.html > warning "irq-xilinx: mismatch in kind-of-intr param" . To fix it cast > intr_mask to u64. It also fixes below shift out of bound warning > 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' Something like this: 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 interrupt the shift is out of bounds, resulting in a mismatch warning. The out of bounds condition was also caught by UBSAN. Fix it by promoting the mask to u64 for the test. Hmm? Thanks, tglx
diff --git a/drivers/irqchip/irq-xilinx-intc.c b/drivers/irqchip/irq-xilinx-intc.c index 238d3d344949..7e08714d507f 100644 --- a/drivers/irqchip/irq-xilinx-intc.c +++ b/drivers/irqchip/irq-xilinx-intc.c @@ -189,7 +189,7 @@ static int __init xilinx_intc_of_init(struct device_node *intc, irqc->intr_mask = 0; } - if (irqc->intr_mask >> irqc->nr_irq) + if ((u64)irqc->intr_mask >> irqc->nr_irq) pr_warn("irq-xilinx: mismatch in kind-of-intr param\n"); pr_info("irq-xilinx: %pOF: num_irq=%d, edge=0x%x\n",
In case num_irq is 32 there is shift out of bound and result in false warning "irq-xilinx: mismatch in kind-of-intr param" . To fix it cast intr_mask to u64. It also fixes below shift out of bound warning 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' Fixes: d50466c90724 ("microblaze: intc: Refactor DT sanity check") Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> --- drivers/irqchip/irq-xilinx-intc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 6a0e38264012809afa24113ee2162dc07f4ed22b