]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.12-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jun 2026 11:26:09 +0000 (12:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jun 2026 11:26:09 +0000 (12:26 +0100)
added patches:
regulator-core-fix-locking-in-regulator_resolve_supply-error-path.patch

queue-6.12/regulator-core-fix-locking-in-regulator_resolve_supply-error-path.patch [new file with mode: 0644]
queue-6.12/series

diff --git a/queue-6.12/regulator-core-fix-locking-in-regulator_resolve_supply-error-path.patch b/queue-6.12/regulator-core-fix-locking-in-regulator_resolve_supply-error-path.patch
new file mode 100644 (file)
index 0000000..0dab769
--- /dev/null
@@ -0,0 +1,66 @@
+From 497330b203d2c59c5ff3fa4c34d14494d7203bc3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik@linaro.org>
+Date: Fri, 9 Jan 2026 08:38:38 +0000
+Subject: regulator: core: fix locking in regulator_resolve_supply() error path
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: AndrĂ© Draszik <andre.draszik@linaro.org>
+
+commit 497330b203d2c59c5ff3fa4c34d14494d7203bc3 upstream.
+
+If late enabling of a supply regulator fails in
+regulator_resolve_supply(), the code currently triggers a lockdep
+warning:
+
+    WARNING: drivers/regulator/core.c:2649 at _regulator_put+0x80/0xa0, CPU#6: kworker/u32:4/596
+    ...
+    Call trace:
+     _regulator_put+0x80/0xa0 (P)
+     regulator_resolve_supply+0x7cc/0xbe0
+     regulator_register_resolve_supply+0x28/0xb8
+
+as the regulator_list_mutex must be held when calling _regulator_put().
+
+To solve this, simply switch to using regulator_put().
+
+While at it, we should also make sure that no concurrent access happens
+to our rdev while we clear out the supply pointer. Add appropriate
+locking to ensure that.
+
+While the code in question will be removed altogether in a follow-up
+commit, I believe it is still beneficial to have this corrected before
+removal for future reference.
+
+Fixes: 36a1f1b6ddc6 ("regulator: core: Fix memory leak in regulator_resolve_supply()")
+Fixes: 8e5356a73604 ("regulator: core: Clear the supply pointer if enabling fails")
+Signed-off-by: AndrĂ© Draszik <andre.draszik@linaro.org>
+Link: https://patch.msgid.link/20260109-regulators-defer-v2-2-1a25dc968e60@linaro.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Nazar Kalashnikov <nazarkalashnikov0@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/regulator/core.c |   10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/drivers/regulator/core.c
++++ b/drivers/regulator/core.c
+@@ -2116,8 +2116,16 @@ static int regulator_resolve_supply(stru
+       if (rdev->use_count) {
+               ret = regulator_enable(rdev->supply);
+               if (ret < 0) {
+-                      _regulator_put(rdev->supply);
++                      struct regulator *supply;
++
++                      regulator_lock_two(rdev, rdev->supply->rdev, &ww_ctx);
++
++                      supply = rdev->supply;
+                       rdev->supply = NULL;
++
++                      regulator_unlock_two(rdev, supply->rdev, &ww_ctx);
++
++                      regulator_put(supply);
+                       goto out;
+               }
+       }
index 6a5480527a6e8e68bc654201365733624821dd32..d402d8dd5bbc270a544e78357bf2769e1a0088c1 100644 (file)
@@ -31,3 +31,4 @@ agp-amd64-fix-broken-error-propagation-in-agp_amd64_probe.patch
 bpf-reject-sleepable-kprobe_multi-programs-at-attach.patch
 selftests-bpf-add-test-to-ensure-kprobe_multi-is-not.patch
 acpi-scan-use-async-schedule-function-in-acpi_scan_c.patch
+regulator-core-fix-locking-in-regulator_resolve_supply-error-path.patch