linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM: Fix dev_pm_put_subsys_data() to not call kfree() while holding device power lock
@ 2013-05-03 20:46 Shuah Khan
  2013-05-04 12:51 ` Pavel Machek
  0 siblings, 1 reply; 11+ messages in thread
From: Shuah Khan @ 2013-05-03 20:46 UTC (permalink / raw)
  To: len.brown@intel.com, rafael.j.wysocki@intel.com, pavel@ucw.cz,
	gregkh@linuxfoundation.org
  Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	shuahkhan@gmail.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1010 bytes --]

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


ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-05-06 20:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-03 20:46 [PATCH] PM: Fix dev_pm_put_subsys_data() to not call kfree() while holding device power lock Shuah Khan
2013-05-04 12:51 ` Pavel Machek
2013-05-06 12:07   ` Rafael J. Wysocki
2013-05-06 12:09     ` Pavel Machek
2013-05-06 14:01       ` Shuah Khan
2013-05-06 19:10         ` Shuah Khan
2013-05-06 19:04       ` [PATCH v2] " Shuah Khan
2013-05-06 19:41         ` gregkh
2013-05-06 19:46           ` Shuah Khan
2013-05-06 19:56           ` Rafael J. Wysocki
2013-05-06 20:33             ` gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).