Messages in this thread Patch in this message | | | From | Shuah Khan <> | Subject | [PATCH] PM: Fix dev_pm_put_subsys_data() to not call kfree() while holding device power lock | Date | Fri, 3 May 2013 20:46:50 +0000 |
| |
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
| |