Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver-core: platform: Catch errors from calls to irq_get_irq_data

irq_get_irq_data() can return NULL, which results in a nasty crash.
Check its return value before passing it on to irqd_set_trigger_type().

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Guenter Roeck and committed by
Greg Kroah-Hartman
60ca5e0d 78618d39

+8 -3
+8 -3
drivers/base/platform.c
··· 108 108 * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER* 109 109 * settings. 110 110 */ 111 - if (r && r->flags & IORESOURCE_BITS) 112 - irqd_set_trigger_type(irq_get_irq_data(r->start), 113 - r->flags & IORESOURCE_BITS); 111 + if (r && r->flags & IORESOURCE_BITS) { 112 + struct irq_data *irqd; 113 + 114 + irqd = irq_get_irq_data(r->start); 115 + if (!irqd) 116 + return -ENXIO; 117 + irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS); 118 + } 114 119 115 120 return r ? r->start : -ENXIO; 116 121 #endif