Skip to content

Commit 1d0326f

Browse files
Marek VasutKAGA-KOKO
authored andcommitted
genirq: Check irq_data_get_irq_chip() return value before use
irq_data_get_irq_chip() can return NULL, however it is expected that this never happens. If a buggy driver leads to NULL being returned from irq_data_get_irq_chip(), warn about it instead of crashing the machine. Signed-off-by: Marek Vasut <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> To: [email protected]
1 parent 9cb1fd0 commit 1d0326f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/irq/manage.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,6 +2619,8 @@ int __irq_get_irqchip_state(struct irq_data *data, enum irqchip_irq_state which,
26192619

26202620
do {
26212621
chip = irq_data_get_irq_chip(data);
2622+
if (WARN_ON_ONCE(!chip))
2623+
return -ENODEV;
26222624
if (chip->irq_get_irqchip_state)
26232625
break;
26242626
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
@@ -2696,6 +2698,8 @@ int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
26962698

26972699
do {
26982700
chip = irq_data_get_irq_chip(data);
2701+
if (WARN_ON_ONCE(!chip))
2702+
return -ENODEV;
26992703
if (chip->irq_set_irqchip_state)
27002704
break;
27012705
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY

0 commit comments

Comments
 (0)