From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbbKMXmU (ORCPT ); Fri, 13 Nov 2015 18:42:20 -0500 Received: from v094114.home.net.pl ([79.96.170.134]:57734 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752174AbbKMXmT (ORCPT ); Fri, 13 Nov 2015 18:42:19 -0500 From: "Rafael J. Wysocki" To: Dmitry Torokhov Cc: Grygorii Strashko , Greg Kroah-Hartman , Tony Lindgren , 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: Sat, 14 Nov 2015 01:11:42 +0100 Message-ID: <2411616.tZ7ojtyi3G@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.1.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20151112185211.GB8494@dtor-ws> References: <20151112182657.GA19785@dtor-ws> <5644DD73.2090904@ti.com> <20151112185211.GB8494@dtor-ws> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > >--- > > > > > >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