Skip to content

Commit

Permalink
regulator: Fix unbalanced disables/enables in regulator_bulk_{enable,…
Browse files Browse the repository at this point in the history
…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.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
  • Loading branch information
Lars-Peter Clausen authored and Liam Girdwood committed Dec 17, 2009
1 parent fa2984d commit eb143ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit eb143ac

Please sign in to comment.