regulator: Fix unbalanced disables/enables in regulator_bulk_{enable,disable} error...
authorLars-Peter Clausen <lars@metafoo.de>
Tue, 15 Dec 2009 13:30:01 +0000 (14:30 +0100)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Thu, 17 Dec 2009 10:27:28 +0000 (10:27 +0000)
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>
drivers/regulator/core.c

index 1af8df203b72ee3fe477c03eed09d726bc9c60c8..686ef270ecf7f01d23bf84a85b5f512be4566f10 100644 (file)
@@ -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;