Skip to content

Commit

Permalink
driver-core: platform: Catch errors from calls to irq_get_irq_data
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
groeck authored and gregkh committed Sep 27, 2016
1 parent 78618d3 commit 60ca5e0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
* IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
* settings.
*/
if (r && r->flags & IORESOURCE_BITS)
irqd_set_trigger_type(irq_get_irq_data(r->start),
r->flags & IORESOURCE_BITS);
if (r && r->flags & IORESOURCE_BITS) {
struct irq_data *irqd;

irqd = irq_get_irq_data(r->start);
if (!irqd)
return -ENXIO;
irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
}

return r ? r->start : -ENXIO;
#endif
Expand Down

0 comments on commit 60ca5e0

Please sign in to comment.