Skip to contentSkip to conversation

irqchip/mst-intc: validate the DT interrupt range

PATCH Applied Pengpeng Hou 2 participants 2 messages Sep 20 – Oct 15

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 irqchip/mst-intc: validate the DT interrupt range

The driver takes an inclusive interrupt range from the device tree without checking its endpoints. A reversed range wraps the unsigned count calculation, and a range larger than MST_INTC_MAX_IRQS exceeds the controller capacity used by the driver.

Reject these ranges before calculating nr_irqs or creating the domain. Check the difference after ordering the endpoints so the validation itself cannot wrap.

The issue was found by our static-analysis tool.

Fixes ad4c938c92af ("irqchip/irq-mst: Add MStar interrupt controller support")
Assisted-by gpt 5

---
Changes since v1:
https://lore.kernel.org/all/[email protected]/
Describe the missing DT range validation directly, keep the condition on one line, and add the introducing Fixes tag as Thomas requested.

 drivers/irqchip/irq-mst-intc.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/irqchip/irq-mst-intc.c +3 -0
index b5335f6fd6d6..1070de5de8cc 100644
@@ -263,6 +263,9 @@ static int __init mst_intc_of_init(struct device_node *dn,
 	    of_property_read_u32_index(dn, "mstar,irqs-map-range", 1, &irq_end))
 		return -EINVAL;
 
+	if (irq_end < irq_start || irq_end - irq_start >= MST_INTC_MAX_IRQS)
+		return -EINVAL;
+
 	cd = kzalloc_obj(*cd);
 	if (!cd)
 		return -ENOMEM;

base-commit: 518e5b794c06c0f0eb40df3e202274a66202c137

Signature · 1 line
2.50.1 (Apple Git-155)
merge bot Applied
#1 lore raw

[tip: irq/drivers] irqchip/mst-intc: Validate the DT interrupt range

The following commit has been merged into the irq/drivers branch of tip:

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     16f25d326e5d3b9fd51bc5e3916ecbffbca63e7b
Gitweb:        https://git.kernel.org/tip/16f25d326e5d3b9fd51bc5e3916ecbffbca63e7b
Author:        Pengpeng Hou <[email protected]>
AuthorDate:    Sun, 20 Sep 2026 11:42:36 +08:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Thu, 15 Oct 2026 11:50:47 +02:00

irqchip/mst-intc: Validate the DT interrupt range

The driver takes an inclusive interrupt range from the device tree without checking its endpoints. A reversed range wraps the unsigned count calculation, and a range larger than MST_INTC_MAX_IRQS exceeds the controller capacity used by the driver.

Reject these ranges before calculating nr_irqs or creating the domain. Check the difference after ordering the endpoints so the validation itself cannot wrap.

The issue was found by our static-analysis tool.

Fixes ad4c938c92af ("irqchip/irq-mst: Add MStar interrupt controller support")
Assisted-by gpt 5
---
 drivers/irqchip/irq-mst-intc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/irqchip/irq-mst-intc.c +3 -0
index b5335f6..1070de5 100644
@@ -263,6 +263,9 @@ static int __init mst_intc_of_init(struct device_node *dn,
 	    of_property_read_u32_index(dn, "mstar,irqs-map-range", 1, &irq_end))
 		return -EINVAL;
 
+	if (irq_end < irq_start || irq_end - irq_start >= MST_INTC_MAX_IRQS)
+		return -EINVAL;
+
 	cd = kzalloc_obj(*cd);
 	if (!cd)
 		return -ENOMEM;