[PATCH 6.19 256/781] regulator: core: dont ignore errors from event forwarding setup

Greg Kroah-Hartman
2026-02-25T01:32:15Z

From: André Draszik <andre.draszik@linaro.org>

[ Upstream commit e23c0a59dabae9166bbea26fc05d08e7d9e900b7 ]

Receiving and forwarding critical supply events seems like they're
important information and we shouldn't ignore errors occurring during
registration for such events.

With this change the supply is unset on event registration failure,
allowing us to potentially retry another time.

Fixes: 433e294c3c5b ("regulator: core: forward undervoltage events downstream by default")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
Link: https://patch.msgid.link/20260109-regulators-defer-v2-6-1a25dc968e60@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/regulator/core.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d0140227fcbdb..8ee33b777f6ce 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() */
--
2.51.0