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


Groups > linux.kernel > #1268180 > unrolled thread

[PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it

Started byDmitry Torokhov <dmitry.torokhov@gmail.com>
First post2015-11-12 19:30 +0100
Last post2015-11-14 00:50 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting  it Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-11-12 19:30 +0100
    Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before  accepting it Grygorii Strashko <grygorii.strashko@ti.com> - 2015-11-12 19:50 +0100
      Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before  accepting it Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-11-12 20:00 +0100
        Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-11-14 00:50 +0100

#1268180 — [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-11-12 19:30 +0100
Subject[PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
Message-ID<qu4Nc-3Zg-37@gated-at.bofh.it>
Check that IRQ number passed to dev_pm_set_wake_irq and
dev_pm_set_dedicated_wake_irq is valid (not negative) before accepting it.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

My recent change to i2c core introduced a code path that led to calling
dev_pm_set_wake_irq(&client->dev, -ENOENT), which succeeded but
obviously did the wrong thing. Checking the IRQ and bailing out early
would have helped noticing this issue earlier.

 drivers/base/power/wakeirq.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
index eb6e674..0d77cd6 100644
--- a/drivers/base/power/wakeirq.c
+++ b/drivers/base/power/wakeirq.c
@@ -68,6 +68,9 @@ int dev_pm_set_wake_irq(struct device *dev, int irq)
 	struct wake_irq *wirq;
 	int err;
 
+	if (irq < 0)
+		return -EINVAL;
+
 	wirq = kzalloc(sizeof(*wirq), GFP_KERNEL);
 	if (!wirq)
 		return -ENOMEM;
@@ -167,6 +170,9 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
 	struct wake_irq *wirq;
 	int err;
 
+	if (irq < 0)
+		return -EINVAL;
+
 	wirq = kzalloc(sizeof(*wirq), GFP_KERNEL);
 	if (!wirq)
 		return -ENOMEM;
-- 
2.6.0.rc2.230.g3dd15c0


-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1268192 — Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it

FromGrygorii Strashko <grygorii.strashko@ti.com>
Date2015-11-12 19:50 +0100
SubjectRe: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
Message-ID<qu56y-46h-7@gated-at.bofh.it>
In reply to#1268180
On 11/12/2015 08:26 PM, Dmitry Torokhov wrote:
> Check that IRQ number passed to dev_pm_set_wake_irq and
> dev_pm_set_dedicated_wake_irq is valid (not negative) before accepting it.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>
> My recent change to i2c core introduced a code path that led to calling
> dev_pm_set_wake_irq(&client->dev, -ENOENT), which succeeded but
> obviously did the wrong thing. Checking the IRQ and bailing out early
> would have helped noticing this issue earlier.
>
>   drivers/base/power/wakeirq.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> index eb6e674..0d77cd6 100644
> --- a/drivers/base/power/wakeirq.c
> +++ b/drivers/base/power/wakeirq.c
> @@ -68,6 +68,9 @@ int dev_pm_set_wake_irq(struct device *dev, int irq)
>   	struct wake_irq *wirq;
>   	int err;
>
> +	if (irq < 0)

<= 0 ?

> +		return -EINVAL;
> +
>   	wirq = kzalloc(sizeof(*wirq), GFP_KERNEL);
>   	if (!wirq)
>   		return -ENOMEM;
> @@ -167,6 +170,9 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
>   	struct wake_irq *wirq;
>   	int err;
>
> +	if (irq < 0)
> +		return -EINVAL;
> +
>   	wirq = kzalloc(sizeof(*wirq), GFP_KERNEL);
>   	if (!wirq)
>   		return -ENOMEM;
>


-- 
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1268209 — Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2015-11-12 20:00 +0100
SubjectRe: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
Message-ID<qu5ge-49Z-19@gated-at.bofh.it>
In reply to#1268192
On Thu, Nov 12, 2015 at 08:41:55PM +0200, Grygorii Strashko wrote:
> On 11/12/2015 08:26 PM, Dmitry Torokhov wrote:
> >Check that IRQ number passed to dev_pm_set_wake_irq and
> >dev_pm_set_dedicated_wake_irq is valid (not negative) before accepting it.
> >
> >Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >---
> >
> >My recent change to i2c core introduced a code path that led to calling
> >dev_pm_set_wake_irq(&client->dev, -ENOENT), which succeeded but
> >obviously did the wrong thing. Checking the IRQ and bailing out early
> >would have helped noticing this issue earlier.
> >
> >  drivers/base/power/wakeirq.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> >diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> >index eb6e674..0d77cd6 100644
> >--- a/drivers/base/power/wakeirq.c
> >+++ b/drivers/base/power/wakeirq.c
> >@@ -68,6 +68,9 @@ int dev_pm_set_wake_irq(struct device *dev, int irq)
> >  	struct wake_irq *wirq;
> >  	int err;
> >
> >+	if (irq < 0)
> 
> <= 0 ?

Maybe. I am still confused whether we treat 0 as invalid or not.

> 
> >+		return -EINVAL;
> >+
> >  	wirq = kzalloc(sizeof(*wirq), GFP_KERNEL);
> >  	if (!wirq)
> >  		return -ENOMEM;
> >@@ -167,6 +170,9 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
> >  	struct wake_irq *wirq;
> >  	int err;
> >
> >+	if (irq < 0)
> >+		return -EINVAL;
> >+
> >  	wirq = kzalloc(sizeof(*wirq), GFP_KERNEL);
> >  	if (!wirq)
> >  		return -ENOMEM;
> >
> 
> 
> -- 
> regards,
> -grygorii

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1269360 — Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2015-11-14 00:50 +0100
SubjectRe: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
Message-ID<quwgq-4yI-3@gated-at.bofh.it>
In reply to#1268209
On Thursday, November 12, 2015 10:52:11 AM Dmitry Torokhov wrote:
> On Thu, Nov 12, 2015 at 08:41:55PM +0200, Grygorii Strashko wrote:
> > On 11/12/2015 08:26 PM, Dmitry Torokhov wrote:
> > >Check that IRQ number passed to dev_pm_set_wake_irq and
> > >dev_pm_set_dedicated_wake_irq is valid (not negative) before accepting it.
> > >
> > >Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > >---
> > >
> > >My recent change to i2c core introduced a code path that led to calling
> > >dev_pm_set_wake_irq(&client->dev, -ENOENT), which succeeded but
> > >obviously did the wrong thing. Checking the IRQ and bailing out early
> > >would have helped noticing this issue earlier.
> > >
> > >  drivers/base/power/wakeirq.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > >
> > >diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> > >index eb6e674..0d77cd6 100644
> > >--- a/drivers/base/power/wakeirq.c
> > >+++ b/drivers/base/power/wakeirq.c
> > >@@ -68,6 +68,9 @@ int dev_pm_set_wake_irq(struct device *dev, int irq)
> > >  	struct wake_irq *wirq;
> > >  	int err;
> > >
> > >+	if (irq < 0)
> > 
> > <= 0 ?
> 
> Maybe. I am still confused whether we treat 0 as invalid or not.

Well, it all boils down to whether or not IRQ 0 may be a valid wakeup IRQ
on any architectures.

In any case, though, we can add that check later, so I'll apply the patch
as is.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web