* [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
@ 2015-11-12 18:26 Dmitry Torokhov
2015-11-12 18:41 ` Grygorii Strashko
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2015-11-12 18:26 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Greg Kroah-Hartman, Tony Lindgren, Grygorii Strashko, linux-pm,
linux-kernel
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
2015-11-12 18:26 [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it Dmitry Torokhov
@ 2015-11-12 18:41 ` Grygorii Strashko
0 siblings, 0 replies; 5+ messages in thread
From: Grygorii Strashko @ 2015-11-12 18:41 UTC (permalink / raw)
To: Dmitry Torokhov, Rafael J. Wysocki
Cc: Greg Kroah-Hartman, Tony Lindgren, linux-pm, linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
@ 2015-11-12 18:41 ` Grygorii Strashko
0 siblings, 0 replies; 5+ messages in thread
From: Grygorii Strashko @ 2015-11-12 18:41 UTC (permalink / raw)
To: Dmitry Torokhov, Rafael J. Wysocki
Cc: Greg Kroah-Hartman, Tony Lindgren, linux-pm, linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
2015-11-12 18:41 ` Grygorii Strashko
(?)
@ 2015-11-12 18:52 ` Dmitry Torokhov
2015-11-14 0:11 ` Rafael J. Wysocki
-1 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2015-11-12 18:52 UTC (permalink / raw)
To: Grygorii Strashko
Cc: Rafael J. Wysocki, Greg Kroah-Hartman, Tony Lindgren, linux-pm,
linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
2015-11-12 18:52 ` Dmitry Torokhov
@ 2015-11-14 0:11 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2015-11-14 0:11 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Grygorii Strashko, Greg Kroah-Hartman, Tony Lindgren, linux-pm,
linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-13 23:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 18:26 [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it Dmitry Torokhov
2015-11-12 18:41 ` Grygorii Strashko
2015-11-12 18:41 ` Grygorii Strashko
2015-11-12 18:52 ` Dmitry Torokhov
2015-11-14 0:11 ` Rafael J. Wysocki
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.