[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1367867093.2953.49.camel@lorien>
Date: Mon, 6 May 2013 19:04:53 +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>,
"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>,
Shuah Khan <shuah.kh@...sung.com>
Subject: [PATCH v2] 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>
Reviewed-by: Pavel Machek <pavel@....cz>
Reviewed-by: Rafael Wysocki <rafael.j.wysocki@...el.com>
---
drivers/base/power/common.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
index 39c3252..e5b99f7 100644
--- a/drivers/base/power/common.c
+++ b/drivers/base/power/common.c
@@ -61,24 +61,26 @@ EXPORT_SYMBOL_GPL(dev_pm_get_subsys_data);
int dev_pm_put_subsys_data(struct device *dev)
{
struct pm_subsys_data *psd;
- int ret = 0;
+ int ret = 1;
spin_lock_irq(&dev->power.lock);
psd = dev_to_psd(dev);
if (!psd) {
- ret = -EINVAL;
goto out;
}
if (--psd->refcount == 0) {
dev->power.subsys_data = NULL;
- kfree(psd);
ret = 1;
+ } else {
+ psd = NULL;
+ ret = 0;
}
out:
spin_unlock_irq(&dev->power.lock);
+ kfree(psd);
return ret;
}
--
1.7.10.4
Powered by blists - more mailing lists