Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D14693C5540 for ; Wed, 17 Jun 2026 10:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781691004; cv=none; b=d8WAbfVoOruD1VFFWJ9/QXWSorrQHGWyXaRcsvFa8aREDDwBKOdhrYg1sIo/JpaIp9QaXuvY3RiJveIuIGDH2VUL+VPkDdgFMEXLjBWvWj0Dmmp0pzZN7F4FNCf4jpLVmX3n/JhzoGLHAx0qimC0HXEVHXEAXceQsEZ8OM0V3kg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781691004; c=relaxed/simple; bh=LsdT55GzrGnni5tHROTuUFTGgK0O+ZZu7Oj5y1cwZ6o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ip0fc0V7ol8SvaUIDuiu9u+Z2+6F8hRiGPvhW8eWsHpZ5CI8U1RE/zihwhqM+IXugMZ+WnZO63L/N5NNEeyoP8ELpx9dzET9QJt8Z0v3VUA7GCbvlFdsQcD38ongA/v4n+590LaHxgcc4kmPhrCwn4nfUN94zBkr7GBflnBBzjs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pqD3H/T/; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pqD3H/T/" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5aa65a184f2so5531308e87.1 for ; Wed, 17 Jun 2026 03:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781691000; x=1782295800; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vGwnZNetQNHsEtMJnoWmHE73vyXkoWstMnhqfVRhjIw=; b=pqD3H/T//2PTz7OFi8PFn8z/JJvFqn7hbs412QerZHR2Y1PTGayfh2diWX+OoHI7yH 7e2MTjd4EG1qL94byX1GtEMBG8vvn8sB69InZIkXjTjxYFWbtRBCGwNb93aSVMeE9ibn O4a++Xo/Gmbdz+BLFw6UvJcyeDoIZ140mOlhn8cZsh7LwKLBWoLzaDnzKQ5miy9bh/os lmtbp/oOuTUHPr03l21GYHoHE6HfgUyPlMEVjSIUKvA8R6U8ibx/Pfu40uY9Tc7A7ODM O5mEMvLQlUS86I0B/YW4/XaeloluL+Y5s4SHuOTe+dvkK/LhALPxzC00+UXkkTC38cqZ ZWPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781691000; x=1782295800; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vGwnZNetQNHsEtMJnoWmHE73vyXkoWstMnhqfVRhjIw=; b=Xm8xcilhei1tomMryVuVftCZVWlalXx5kwNVxXkMPIPeg8ZAJEVdTF2Q38AP4RqAwY DsMv0qtJTJ0fIyQofMhP1s6PCvLmeHVNfi+qKH2h5w/tuzvZ3beP4R9/YK/vVvFpwbxI FUnbfw6nL0owgu7SpZER5xo64mgGCms9bJUZK77EInEYsrj66VipRkH3hu3CwUqXN8d/ BcnyAStN3n7zzTpd2iPv0ex/NmwmR+iI0bxT5MUCQTsoAGwfszZ3gPafiebe7fFu1H2w Jgwp7TaFRpw/wIcbKkmglow1S7Ws/X2rpspeP9itKTpWhVPePL2t2ZWkmdv7S6cD4GgM 3lBA== X-Forwarded-Encrypted: i=1; AFNElJ8e+lZW84q+Waj/UWIuRYhg2d+XrBLoDTEolCHlmY7QWd0mQvWQQjBgvjxBWAFV4yWcqr+UhL1kgg4y1zI=@vger.kernel.org X-Gm-Message-State: AOJu0YzO8zfEnZTGRewRnEKOm19RnEm4nA2aa28LTTmKGLjUcvAqjP3X fh1MENgHyUJ81XXA8L8Wo0boIMZ7xsa7h0furBQGR7ui/ES2s3Gn+3i7 X-Gm-Gg: AfdE7cmdMwJOmiKYQJ5vs1/KP9FmEqSkMS8rD05aXicgrRAUgIakiyx2WmSxG7z7m0/ t+V7OF5OUKDSJoA0mmZjFJWEUP/lJuWTChMwmis0TtrKlSn0BptY1iclx1jeEZEii7tJSfcbBTS +uLEu7GUGO7lNQgbUqdjBI6OccVmAXN0uaMvswyIZMAtR8vBMYJfNJS5dj9QwsQ47rYpFtmWpAJ kcIOXQ9B6eLCCYBMALgyDIuS1YllwnVfhAUFCwm+l97elnT5YfFahSC1te3vYse+ftDSB9OWdoX WQgdxIojFnQcSUuKa7wz3xf4MH/YM6TD6jYd0mwHLq79B+g5lig+uQGaFYCBrBuAh6EbL/iFAMi xAhBT1Ax3rf2/mkEXlKOW6ycao2jRgRDpUwQtEY2AXPlQSF/j8BBz6uOehKwc53mk6WPVCoQ9BI QPqnZ6+sFcxla3SfMzgkBCoudS6mNxssBp X-Received: by 2002:a05:6512:3e1a:b0:5ad:4c10:e990 with SMTP id 2adb3069b0e04-5ad4c202d17mr91232e87.43.1781690999742; Wed, 17 Jun 2026 03:09:59 -0700 (PDT) Received: from cherrypc.astra-academy.ru ([81.9.21.4]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ad2e1a726asm4301506e87.44.2026.06.17.03.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 03:09:59 -0700 (PDT) From: Nazar Kalashnikov To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Nazar Kalashnikov , Liam Girdwood , Mark Brown , Javier Martinez Canillas , Jon Hunter , linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, =?UTF-8?q?Andr=C3=A9=20Draszik?= Subject: [PATCH 5.10/5.15/6.1/6.6/6.12/6.18] regulator: core: fix locking in regulator_resolve_supply() error path Date: Wed, 17 Jun 2026 16:10:12 +0300 Message-ID: <20260617131018.880160-1-nazarkalashnikov0@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: André Draszik 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 Link: https://patch.msgid.link/20260109-regulators-defer-v2-2-1a25dc968e60@linaro.org Signed-off-by: Mark Brown Signed-off-by: Nazar Kalashnikov --- Backport fix for CVE-2026-46252 drivers/regulator/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 765bd1b5deb3..761a3f905859 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2159,8 +2159,16 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) 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; } } -- 2.47.3