From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"André Draszik" <andre.draszik@linaro.org>,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 6/8] regulator: core: Respect is_locked when disabling supply on enable failure
Date: Fri, 27 Nov 2026 18:35:46 +0000 [thread overview]
Message-ID: <20261127183624.3341010-7-lee@kernel.org> (raw)
In-Reply-To: <20261127183624.3341010-1-lee@kernel.org>
When set_machine_constraints() is called with is_locked set from
regulator_resolve_supply(), it already holds regulator_lock_dependent()
and uses _regulator_enable() to enable rdev->supply. If
_regulator_do_enable() then fails, however, the error path calls
regulator_disable() unconditionally, re-entering
regulator_lock_dependent() and inverting regulator_list_mutex against
the held ww_mutex locks.
Use _regulator_disable() when is_locked is true, matching the enable
path above.
Fixes: 8d38423d9dea ("regulator: core: don't fail regulator_register() with missing required supply")
Closes: https://sashiko.dev/#/bug/linux-e745c649-52f1-4f96-966d-49c3f8addf7a
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/regulator/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 18ec8b77e620..121b0b49b8df 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1688,8 +1688,12 @@ static int set_machine_constraints(struct regulator_dev *rdev,
ret = _regulator_do_enable(rdev);
if (ret < 0 && ret != -EINVAL) {
rdev_err(rdev, "failed to enable: %pe\n", ERR_PTR(ret));
- if (supply_enabled)
- regulator_disable(rdev->supply);
+ if (supply_enabled) {
+ if (is_locked)
+ _regulator_disable(rdev->supply);
+ else
+ regulator_disable(rdev->supply);
+ }
return ret;
}
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-27 18:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 18:35 [PATCH 0/8] regulator: Fix locking, OOB read, lifetime, and global state bugs (batch 2) Lee Jones
2026-11-27 18:35 ` [PATCH 1/8] regulator: core: Defer supply cleanup and unregister event forwarding on error Lee Jones
2026-11-30 23:48 ` Doug Anderson
2026-12-01 11:02 ` Lee Jones
2026-11-27 18:35 ` [PATCH 2/8] regulator: max8907: Duplicate of_regulator_match table per device Lee Jones
2026-11-27 18:35 ` [PATCH 3/8] regulator: tps6594-regulator: Use dedicated handler for external regulator IRQs Lee Jones
2026-11-27 18:35 ` [PATCH 4/8] regulator: tps65910: Fix OOB read and bit shift in external sleep config Lee Jones
2026-11-27 18:35 ` [PATCH 5/8] regulator: tps6594-regulator: Bind IRQ resources to child platform device Lee Jones
2026-11-27 18:35 ` Lee Jones [this message]
2026-11-27 18:35 ` [PATCH 7/8] regulator: of: Guard against NULL device_node in of_regulator_bulk_get_all() Lee Jones
2026-11-27 18:35 ` [PATCH 8/8] regulator: aat2870: Duplicate regulator data per device Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127183624.3341010-7-lee@kernel.org \
--to=lee@kernel.org \
--cc=andre.draszik@linaro.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.