[PATCH] PM: Fix dev_pm_put_subsys_data() to not call kfree() whileholding device power lock

From: Shuah Khan
Date: Fri May 03 2013 - 16:46:56 EST


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@xxxxxxxxxxx>
---
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


N‹§²æìr¸›yúèšØb²X¬¶ÇvØ^–)Þ{.nÇ+‰·¥Š{±‘êçzX§¶›¡Ü}©ž²ÆzÚ&j:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú&¢)ßf”ù^jÇy§m…á@A«a¶Úÿ 0¶ìh®å’i