Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1482907

[PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data

From Guenter Roeck <linux@roeck-us.net>
Newsgroups linux.kernel
Subject [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data
Date 2016-09-14 05:40 +0200
Message-ID <sh9df-2Vz-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/base/platform.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6482d47deb50..521c8ff28158 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -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
-- 
2.5.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data Guenter Roeck <linux@roeck-us.net> - 2016-09-14 05:40 +0200
  Re: [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data Linus Walleij <linus.walleij@linaro.org> - 2016-09-14 11:10 +0200
    Re: [PATCH] driver-core: platform: Catch errors from calls to  irq_get_irq_data Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-14 11:50 +0200
      Re: [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data Linus Walleij <linus.walleij@linaro.org> - 2016-09-14 13:20 +0200
      Re: [PATCH] driver-core: platform: Catch errors from calls to  irq_get_irq_data Guenter Roeck <linux@roeck-us.net> - 2016-09-14 16:30 +0200

csiph-web