[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1367614010.8452.2.camel@lorien>
Date: Fri, 3 May 2013 20:46:50 +0000
From: Shuah Khan <shuah.kh@...sung.com>
To: "len.brown@...el.com" <len.brown@...el.com>,
"rafael.j.wysocki@...el.com" <rafael.j.wysocki@...el.com>,
"pavel@....cz" <pavel@....cz>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC: "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"shuahkhan@...il.com" <shuahkhan@...il.com>
Subject: [PATCH] PM: Fix dev_pm_put_subsys_data() to not call kfree() while
holding device power lock
dev_pm_put_subsys_data() calls kfree() while holding device power lock, when
the reference count is 0. Fix it to call kfree() after releasing the lock.
Signed-off-by: Shuah Khan <shuah.kh@...sung.com>
---
drivers/base/power/common.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
index 39c3252..da05fe2 100644
--- a/drivers/base/power/common.c
+++ b/drivers/base/power/common.c
@@ -73,13 +73,17 @@ int dev_pm_put_subsys_data(struct device *dev)
if (--psd->refcount == 0) {
dev->power.subsys_data = NULL;
- kfree(psd);
ret = 1;
}
out:
spin_unlock_irq(&dev->power.lock);
+ if (ret == 1) {
+ /* kfree() verifies that its argument is nonzero. */
+ kfree(psd);
+ }
+
return ret;
}
EXPORT_SYMBOL_GPL(dev_pm_put_subsys_data);
--
1.7.10.4
Powered by blists - more mailing lists