All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: Actually free the regulator in devm_regulator_put()
@ 2012-05-07 11:41 Mark Brown
  2012-05-07 12:10 ` Liam Girdwood
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2012-05-07 11:41 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, Mark Brown

It turns out that (quite surprisingly) devres_destroy() only undoes the
devres mapping, it doesn't destroy the underlying resource, meaning that
anything using devm_regulator_put() would leak. While we wait for the new
devres_release() which does what we want to get merged open code it in
devm_regulator_put().

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/regulator/core.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e70dd38..046fb1b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1431,7 +1431,10 @@ void devm_regulator_put(struct regulator *regulator)
 
 	rc = devres_destroy(regulator->dev, devm_regulator_release,
 			    devm_regulator_match, regulator);
-	WARN_ON(rc);
+	if (rc == 0)
+		regulator_put(regulator);
+	else
+		WARN_ON(rc);
 }
 EXPORT_SYMBOL_GPL(devm_regulator_put);
 
-- 
1.7.10


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

* Re: [PATCH] regulator: Actually free the regulator in devm_regulator_put()
  2012-05-07 11:41 [PATCH] regulator: Actually free the regulator in devm_regulator_put() Mark Brown
@ 2012-05-07 12:10 ` Liam Girdwood
  0 siblings, 0 replies; 2+ messages in thread
From: Liam Girdwood @ 2012-05-07 12:10 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel

On Mon, 2012-05-07 at 12:41 +0100, Mark Brown wrote:
> It turns out that (quite surprisingly) devres_destroy() only undoes the
> devres mapping, it doesn't destroy the underlying resource, meaning that
> anything using devm_regulator_put() would leak. While we wait for the new
> devres_release() which does what we want to get merged open code it in
> devm_regulator_put().
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---

Acked-by: Liam Girdwood <lrg@ti.com>


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

end of thread, other threads:[~2012-05-07 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-07 11:41 [PATCH] regulator: Actually free the regulator in devm_regulator_put() Mark Brown
2012-05-07 12:10 ` Liam Girdwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.