Skip to contentSkip to conversation

regulator: Actually free the regulator in devm_regulator_put()

PATCH In review Mark Brown 2 participants 2 messages May 7, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 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().

---
 drivers/regulator/core.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/regulator/core.c +4 -1
index e70dd38..046fb1b 100644
@@ -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);
 
Signature · 1 line
1.7.10
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · 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().

---