Merge remote-tracking branch 'regulator/fix/core' into tmp
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index da9782b..4a7790c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3057,9 +3057,13 @@
 	return 0;
 
 err:
-	pr_err("Failed to enable %s: %d\n", consumers[i].supply, ret);
-	while (--i >= 0)
-		regulator_disable(consumers[i].consumer);
+	for (i = 0; i < num_consumers; i++) {
+		if (consumers[i].ret < 0)
+			pr_err("Failed to enable %s: %d\n", consumers[i].supply,
+			       consumers[i].ret);
+		else
+			regulator_disable(consumers[i].consumer);
+	}
 
 	return ret;
 }