Skip to content

Commit

Permalink
regulator: Actually free the regulator in devm_regulator_put()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark Brown committed May 7, 2012
1 parent f55205f commit 968c2c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 968c2c1

Please sign in to comment.