genirq: Check irq_data_get_irq_chip() return value before use
PATCH v2 1/1 genirq: Check irq_data_get_irq_chip() return value before use
The irq_data_get_irq_chip() can return NULL, however it is expected that this never happens. If a buggy driver leads to a NULL being returned from irq_data_get_irq_chip(), warn about it.
Signed-off-by Marek Vasut <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Marc Zyngier <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Thomas Gleixner <[email protected]>
To: [email protected]
---
V2: - Use WARN_ON_ONCE() and return -ENODEV
- Reword the commit message
--- kernel/irq/manage.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/irq/manage.c +4 -0
@@ -2619,6 +2619,8 @@ int __irq_get_irqchip_state(struct irq_data *data, enum irqchip_irq_state which, do { chip = irq_data_get_irq_chip(data); + if (WARN_ON_ONCE(!chip)) + return -ENODEV; if (chip->irq_get_irqchip_state) break; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
@@ -2696,6 +2698,8 @@ int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which, do { chip = irq_data_get_irq_chip(data); + if (WARN_ON_ONCE(!chip)) + return -ENODEV; if (chip->irq_set_irqchip_state) break; #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel