[PATCH] power: pwrseq: fix missing state_lock in pwrseq_power_on() error path

Ziyi Guo posted 1 patch 1 week, 2 days ago
drivers/power/sequencing/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] power: pwrseq: fix missing state_lock in pwrseq_power_on() error path
Posted by Ziyi Guo 1 week, 2 days ago
pwrseq_power_on() calls pwrseq_unit_disable() when the
post_enable callback fails. However, this call is outside the
scoped_guard(mutex, &pwrseq->state_lock) block that ends.

pwrseq_unit_disable() has lockdep_assert_held(&pwrseq->state_lock),
which will fail when called from this error path.

Add the scoped_guard block to cover the post_enable callback and its
error handling to ensure the lock is held when pwrseq_unit_disable() is
called.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
---
 drivers/power/sequencing/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/core.c
index 190564e55988..1fcf0af7cc0b 100644
--- a/drivers/power/sequencing/core.c
+++ b/drivers/power/sequencing/core.c
@@ -914,8 +914,10 @@ int pwrseq_power_on(struct pwrseq_desc *desc)
 	if (target->post_enable) {
 		ret = target->post_enable(pwrseq);
 		if (ret) {
-			pwrseq_unit_disable(pwrseq, unit);
-			desc->powered_on = false;
+			scoped_guard(mutex, &pwrseq->state_lock) {
+				pwrseq_unit_disable(pwrseq, unit);
+				desc->powered_on = false;
+			}
 		}
 	}
 
-- 
2.34.1
Re: [PATCH] power: pwrseq: fix missing state_lock in pwrseq_power_on() error path
Posted by Bartosz Golaszewski 4 days, 19 hours ago
On Fri, 30 Jan 2026 18:26:51 +0000, Ziyi Guo wrote:
> pwrseq_power_on() calls pwrseq_unit_disable() when the
> post_enable callback fails. However, this call is outside the
> scoped_guard(mutex, &pwrseq->state_lock) block that ends.
> 
> pwrseq_unit_disable() has lockdep_assert_held(&pwrseq->state_lock),
> which will fail when called from this error path.
> 
> [...]

Applied, thanks!

[1/1] power: pwrseq: fix missing state_lock in pwrseq_power_on() error path
      https://git.kernel.org/brgl/c/e1dccb485c2876ac1318f36ccc0155416c633a48

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>