Skip to contentSkip to conversation

regulator: fixed regulator_bulk_enable unwinding code

PATCH In review Jonghwan Choi 2 participants 2 messages Apr 23, 2013 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: fixed regulator_bulk_enable unwinding code

3.8-stable review patch. If anyone has any objections, please let me know.

------------------

From: "Andrzej Hajda <[email protected]>"

commit fbe31057fafebdc2811a7101b8b4a0460f5417d1 upstream.

Unwinding code disables all successfully enabled regulators. Error is logged for every failed regulator.

---
 drivers/regulator/core.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/regulator/core.c +3 -3
index 5a0f54a..e56185b 100644
@@ -3032,9 +3032,13 @@ int regulator_bulk_enable(int num_consumers,
 	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;
}

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 1 line · Jonghwan Choi

3.8-stable review patch. If anyone has any objections, please let me know.

Thanks, I believe this is also applicable to 3.4.y and 3.5.y.

Cheers,
--
Luis

Quoted 47 lines

------------------

From: "Andrzej Hajda <[email protected]>"

commit fbe31057fafebdc2811a7101b8b4a0460f5417d1 upstream.

Unwinding code disables all successfully enabled regulators. Error is logged for every failed regulator.

---
 drivers/regulator/core.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/regulator/core.c +7 -3
index 5a0f54a..e56185b 100644
@@ -3032,9 +3032,13 @@ int regulator_bulk_enable(int num_consumers,
 	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;

}

Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html