From: Lars-Peter Clausen Date: Tue, 15 Dec 2009 13:30:01 +0000 (+0100) Subject: regulator: Fix unbalanced disables/enables in regulator_bulk_{enable,disable} error... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eb143ac1b9f56ca9c6dc782d795acda1f60c5fd2;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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. Signed-off-by: Lars-Peter Clausen Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 1af8df203b72..686ef270ecf7 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -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;