From nobody Mon Feb 9 17:35:42 2026 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 87BC6312800 for ; Sat, 27 Dec 2025 12:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837938; cv=none; b=ivF7lpONLIMsdPOsFP0xnHoF+5vY2MRlLTrGf1l5ZIEz1yK6aLu61k/R0AIzVx3whP5QyDoUeKctKPde5qZt/u12pYjiCsZ+L7B1PLmQOnaCnAQnkMhOfv6lXPhajB+xc54nNBzdfYgm0qbbYKQKUI5cHE2+FjLiZpF6IMQvh6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837938; c=relaxed/simple; bh=yOXA6IU92rs/sPMHoI+khftQph5Q3jgI9j+NUGdNLjQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cFOQaaLoGcv3OIcFc+6zhDYvctd6mQHOp4FoZwHraOki5azEmKKpVsGrB1e7Z8fc99w53ASm+AhwZpYl7i1mYOlJzpbEaieZlK9CI7q8GNj2kfGBP00UzWQss/ZSnltM5bjl2RDqakWeSp/5A3dkakKPKyuzZDQ+7tZo+32/B+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Ivg0H0dv; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ivg0H0dv" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-64b9cb94ff5so9041828a12.2 for ; Sat, 27 Dec 2025 04:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837869; x=1767442669; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OMJh7i2y//JuRngdUmq5ugjIn2B/PMBcQErV6SQUmlw=; b=Ivg0H0dvnBNHaIWJIYjQiKhkz2GnehOBf4GlYeTPJ11S6+HpHkt9s472huhHUxENVF qHR9xuNmIhz2m/PTYmfsnAgFBc+wBK4/snz9q+PC7NezKpqVr6JXoBAvt5AHKOGB1bVo Cf5uTh0UfAuNuAblJAYUQ8jNFQdm5PnjCHRieIxR8lfdMPLE6MFCDjHkotjOsKxpWhof vWlZ9yM3Tb2UjJapWpBCq+1fdXoV6gDQCUU1LyUVr9jEdS9ygn/4y+eoLj0muNyOXDz3 KsSGq8YyaeNwEBgnRVys734zNyk8QDnDCYjwMxT8/t/dx1mna8hszRljEkt3f/JrCTZM 3SJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837869; x=1767442669; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=OMJh7i2y//JuRngdUmq5ugjIn2B/PMBcQErV6SQUmlw=; b=oh8nCDpS18pCP+HsuPr//bctcvWfyTv8JivTMzkci1mGsMOBPaXjY5QZy5XH7jT/Dy NekjwxHYfCw8mf4vTsNdylWLhbverkpKV1S1VJKhTOI0Ve1eGXcW1688FPwP5Lj+HYxp yCc1OiYTYgqtBPztKVGxnANJLRttCmeS/MMc3/EbalCZu0Ljizl26BRgCbTHyaNfyPYj T+ktwpH/loCVIYRu5WCbgBkcHom/Gv1jvgI2GXZ6L4mItHwZSstzskMTv7f/dSfPhJr4 EcvS8dPc0WAJ+qN19GRAX7y2iu0qfRePFH+Pj4ryHq3MekPp/+yzxtH+8+zEBAOtbICe 8+Yw== X-Forwarded-Encrypted: i=1; AJvYcCWHmyiwjM6/8Op3cytg5qcmthXGk6EXrOw7CPYyDLYLm7WtY0EzWL8iNb9hl0sxcQxIuozpr1s8TkKYBog=@vger.kernel.org X-Gm-Message-State: AOJu0YxSVz7LPRRK+rv7vPXjA0pQqBGQqEhRsuooBL5Tc5fA7QZWplgo oQnA6FTks1u4hWHHIZjViDEzlJWsutId6rX5SQLCDzsGV3s4D5/i4MmnFup9/QoobIU= X-Gm-Gg: AY/fxX4/ckJqxG1bN9x6D/orIhX5toJFwd3d9qli4iOCurK/Cj8MiEwgsCEMFIIpSYZ shx2Y1mqiGToLif2X/l6izKiU16jvRg9I4dYYbPcsC2oJ3YnjXs3qnrX9x+0i92WfXECAczQunC Y1yHtv83LpOxdfamHUJNYFyCuNGsk6jhLKz/X7vdi2ogcFPkobRDtIJol3REcSt2N5UZQZFvVD6 wMdUFD9EpqUpAObD0UtXV5N9u4RmsvMKmKcwnLyAGpwhzdTPyqCXmKEFBZjcEP4Osi+4o9LnOe8 wZ3LyM8W3Pxdr85vrarYjeOB7XksD0mNF05hZC9Yc1uu5VWgIwkCbCM/Jw6JnnNnYYJtJPDVw4W f/B+50QquOITyFknbukjXjR4kTzG8gUktF1lRTQO2c/geVL0vyz3FH+VMhMWsGthyLrzx83r2Nf /TFs4Uzio7G/628F52CsLWKb03uWVyGuzvA1wJ28DN2P70LCyhdLdazDFnE3AwC01MT9x0M3/l7 Ohz1g== X-Google-Smtp-Source: AGHT+IF0PlolWEbFwtEpPFUfU+LHipgZ1hi8LcRzdHZUBBAM0q/hEM3uPs6eHk1P0RLek8hz7wgFwA== X-Received: by 2002:a17:907:6ea4:b0:b80:f2e:6e1 with SMTP id a640c23a62f3a-b803722a7demr2716142566b.43.1766837868786; Sat, 27 Dec 2025 04:17:48 -0800 (PST) Received: from puffmais2.c.googlers.com (244.175.141.34.bc.googleusercontent.com. [34.141.175.244]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8037f18575sm2616274666b.54.2025.12.27.04.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 04:17:48 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:46 +0000 Subject: [PATCH 2/8] regulator: core: fix locking in regulator_resolve_supply() error path 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: quoted-printable Message-Id: <20251227-regulators-defer-v1-2-3104b22d84cb@linaro.org> References: <20251227-regulators-defer-v1-0-3104b22d84cb@linaro.org> In-Reply-To: <20251227-regulators-defer-v1-0-3104b22d84cb@linaro.org> To: Liam Girdwood , Mark Brown , Javier Martinez Canillas , Jon Hunter , Dmitry Baryshkov , Oleksij Rempel Cc: Peter Griffin , Tudor Ambarus , Will McVicker , Juan Yescas , kernel-team@android.com, linux-kernel@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Draszik?= X-Mailer: b4 0.14.2 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=C3=A9 Draszik --- 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 a723bd00e1716c2c3899c63314c6249015698216..48c091de68d81e3e89eacecd852= 6255ab9a446b2 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2285,8 +2285,16 @@ static int regulator_resolve_supply(struct regulator= _dev *rdev) if (rdev->use_count) { ret =3D regulator_enable(rdev->supply); if (ret < 0) { - _regulator_put(rdev->supply); + struct regulator *supply; + + regulator_lock_two(rdev, rdev->supply->rdev, &ww_ctx); + + supply =3D rdev->supply; rdev->supply =3D NULL; + + regulator_unlock_two(rdev, supply->rdev, &ww_ctx); + + regulator_put(supply); goto out; } } --=20 2.52.0.351.gbe84eed79e-goog