summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index fd8da369c052..86dbee3ffda0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2273,10 +2273,21 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
* under-voltage.
*/
ret = register_regulator_event_forwarding(rdev);
- if (ret < 0)
+ if (ret < 0) {
+ struct regulator *supply;
+
rdev_warn(rdev, "Failed to register event forwarding: %pe\n",
ERR_PTR(ret));
+ supply = rdev->supply;
+ rdev->supply = NULL;
+
+ regulator_unlock_two(rdev, supply->rdev, &ww_ctx);
+
+ regulator_put(supply);
+ goto out;
+ }
+
regulator_unlock_two(rdev, r, &ww_ctx);
/* rdev->supply was created in set_supply() */