[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