lkml.org 
[lkml]   [2015]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] PM / wakeirq: check that wake IRQ is valid before accepting 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


\
 
 \ /
  Last update: 2015-11-12 19:41    [W:0.426 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site