summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonio Borneo <antonio.borneo@foss.st.com>2022-06-06 18:27:54 +0200
committerMarc Zyngier <maz@kernel.org>2022-07-07 10:07:44 +0200
commitc16ae609214e835692c33b1a090b5a15bf1b9e7e (patch)
treeacf785333a960d4539c5ea2873f38a73d6f44829
parentirqchip/stm32-exti: Fix irq_mask/irq_unmask for direct events (diff)
downloadlinux-c16ae609214e835692c33b1a090b5a15bf1b9e7e.tar.xz
linux-c16ae609214e835692c33b1a090b5a15bf1b9e7e.zip
irqchip/stm32-exti: Prevent illegal read due to unbounded DT value
The value hwirq is received from DT. If it exceeds the maximum valid value it causes the code to address unexisting irq chips reading outside the array boundary. Check the value of hwirq before using it. Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220606162757.415354-4-antonio.borneo@foss.st.com
-rw-r--r--drivers/irqchip/irq-stm32-exti.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
index 1145f064faa8..e2722e499ae5 100644
--- a/drivers/irqchip/irq-stm32-exti.c
+++ b/drivers/irqchip/irq-stm32-exti.c
@@ -713,6 +713,9 @@ static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
int bank;
hwirq = fwspec->param[0];
+ if (hwirq >= host_data->drv_data->bank_nr * IRQS_PER_BANK)
+ return -EINVAL;
+
bank = hwirq / IRQS_PER_BANK;
chip_data = &host_data->chips_data[bank];