Skip to contentSkip to conversation

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

PATCH In review Guenter Roeck 3 participants 5 messages Sep 14, 2016 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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().

---
 drivers/base/platform.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/base/platform.c +8 -3
index 6482d47deb50..521c8ff28158 100644
@@ -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
Signature · 1 line
2.5.0
#2 lore raw
Quoted 10 lines · Linus Walleij
Quoted 4 lines · Guenter Roeck

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().

Should probably be tagged for stable.

Why, are there any systems that are currently broken without this change right now?

thanks,

greg k-h

#3 lore raw
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Linus Walleij
Quoted 3 lines · Guenter Roeck

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().

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Should probably be tagged for stable.

Why, are there any systems that are currently broken without this change right now?

I guess Günther can tell if there are any, but I guess you're right, no need to rush it for stable then.

Yours,
Linus Walleij

#4 lore raw
In reply to Greg Kroah-Hartman
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Linus Walleij
Quoted 3 lines · Guenter Roeck

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().

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Should probably be tagged for stable.

Why, are there any systems that are currently broken without this change right now?

I only see it in -next, and that is due to a patch there.

Guenter