Skip to contentSkip to conversation

regulator: Fix unbalanced disables/enables in regulator_bulk_{enable,disable} error path

PATCH In review Lars-Peter Clausen 3 participants 3 messages Dec 15, 2009 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: Fix unbalanced disables/enables in regulator_bulk_{enable,disable} error path

Currently it is possible for regulator_bulk_{enable,disable} operations to generate unbalanced regulator_{disable,enable} calls in its error path. In case of an error only those regulators of the bulk operation which actually had been enabled/disabled should get their original state restored.

---
 drivers/regulator/core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/core.c +2 -2
index 1af8df2..686ef27 100644
@@ -1977,7 +1977,7 @@ int regulator_bulk_enable(int num_consumers,
 
 err:
 	printk(KERN_ERR "Failed to enable %s: %d\n", consumers[i].supply, ret);
-	for (i = 0; i < num_consumers; i++)
+	for (--i; i >= 0; --i)
 		regulator_disable(consumers[i].consumer);
 
 	return ret;
@@ -2013,7 +2013,7 @@ int regulator_bulk_disable(int num_consumers,
 err:
 	printk(KERN_ERR "Failed to disable %s: %d\n", consumers[i].supply,
 	       ret);
-	for (i = 0; i < num_consumers; i++)
+	for (--i; i >= 0; --i)
 		regulator_enable(consumers[i].consumer);
 
 	return ret;
Signature · 1 line
1.5.6.5
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Lars-Peter Clausen

Currently it is possible for regulator_bulk_{enable,disable} operations to generate unbalanced regulator_{disable,enable} calls in its error path. In case of an error only those regulators of the bulk operation which actually had been enabled/disabled should get their original state restored.

#2 lore raw
In reply to Lars-Peter Clausen
Quoted 10 lines · Lars-Peter Clausen

Currently it is possible for regulator_bulk_{enable,disable} operations to generate unbalanced regulator_{disable,enable} calls in its error path. In case of an error only those regulators of the bulk operation which actually had been enabled/disabled should get their original state restored.

---
 drivers/regulator/core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Applied for 2.6.33.

Thanks

Liam