lkml.org 
[lkml]   [2013]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] PM: Fix dev_pm_put_subsys_data() to not call kfree() while holding device power lock
Date
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@samsung.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

\
 
 \ /
  Last update: 2013-05-03 23:01    [W:0.091 / U:3.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site