All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data
@ 2016-09-14  3:32 Guenter Roeck
  2016-09-14  9:06 ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2016-09-14  3:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Vladimir Zapolskiy, Linus Walleij, 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().

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data
  2016-09-14  3:32 [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data Guenter Roeck
@ 2016-09-14  9:06 ` Linus Walleij
  2016-09-14  9:44   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2016-09-14  9:06 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Greg Kroah-Hartman, linux-kernel, Vladimir Zapolskiy

On Wed, Sep 14, 2016 at 5:32 AM, Guenter Roeck <linux@roeck-us.net> wrote:

> 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>

Should probably be tagged for stable.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data
  2016-09-14  9:06 ` Linus Walleij
@ 2016-09-14  9:44   ` Greg Kroah-Hartman
  2016-09-14 11:12     ` Linus Walleij
  2016-09-14 14:29     ` Guenter Roeck
  0 siblings, 2 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2016-09-14  9:44 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Guenter Roeck, linux-kernel, Vladimir Zapolskiy

On Wed, Sep 14, 2016 at 11:06:08AM +0200, Linus Walleij wrote:
> On Wed, Sep 14, 2016 at 5:32 AM, Guenter Roeck <linux@roeck-us.net> wrote:
> 
> > 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>
> 
> Should probably be tagged for stable.

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

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data
  2016-09-14  9:44   ` Greg Kroah-Hartman
@ 2016-09-14 11:12     ` Linus Walleij
  2016-09-14 14:29     ` Guenter Roeck
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2016-09-14 11:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Guenter Roeck, linux-kernel, Vladimir Zapolskiy

On Wed, Sep 14, 2016 at 11:44 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Wed, Sep 14, 2016 at 11:06:08AM +0200, Linus Walleij wrote:
>> On Wed, Sep 14, 2016 at 5:32 AM, Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> > 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>
>>
>> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data
  2016-09-14  9:44   ` Greg Kroah-Hartman
  2016-09-14 11:12     ` Linus Walleij
@ 2016-09-14 14:29     ` Guenter Roeck
  1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2016-09-14 14:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Linus Walleij; +Cc: linux-kernel, Vladimir Zapolskiy

On 09/14/2016 02:44 AM, Greg Kroah-Hartman wrote:
> On Wed, Sep 14, 2016 at 11:06:08AM +0200, Linus Walleij wrote:
>> On Wed, Sep 14, 2016 at 5:32 AM, Guenter Roeck <linux@roeck-us.net> wrote:
>>
>>> 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>
>>
>> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-14 14:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-14  3:32 [PATCH] driver-core: platform: Catch errors from calls to irq_get_irq_data Guenter Roeck
2016-09-14  9:06 ` Linus Walleij
2016-09-14  9:44   ` Greg Kroah-Hartman
2016-09-14 11:12     ` Linus Walleij
2016-09-14 14:29     ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.