2012-05-07 11:41:12

by Mark Brown

[permalink] [raw]
Subject: [PATCH] regulator: Actually free the regulator in devm_regulator_put()

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 <[email protected]>
---
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


2012-05-07 12:10:16

by Liam Girdwood

[permalink] [raw]
Subject: Re: [PATCH] regulator: Actually free the regulator in devm_regulator_put()

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 <[email protected]>
> ---

Acked-by: Liam Girdwood <[email protected]>