All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tony Lindgren <tony@atomide.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PM / wakeirq: check that wake IRQ is valid before accepting it
Date: Thu, 12 Nov 2015 10:52:11 -0800	[thread overview]
Message-ID: <20151112185211.GB8494@dtor-ws> (raw)
In-Reply-To: <5644DD73.2090904@ti.com>

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

  reply	other threads:[~2015-11-12 18:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-11-14  0:11     ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151112185211.GB8494@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=grygorii.strashko@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.