[PATCH] regulator: core: Fix rdev reference leak in regulator_resolve_supply()

Wentao Liang posted 1 patch 1 week ago
drivers/regulator/core.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] regulator: core: Fix rdev reference leak in regulator_resolve_supply()
Posted by Wentao Liang 1 week ago
regulator_resolve_supply() takes a reference on the looked-up regulator
with regulator_dev_lookup(), but when the supply resolves to the
regulator itself that reference is never dropped: it leaks on the early
return and is lost as well when r is replaced with the dummy regulator.

Release the reference before handling the self-referent case.

Fixes: 4b639e254d3d ("regulator: avoid resolve_supply() infinite recursion")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/regulator/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 0ae11a521943..31893c7decd5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2221,6 +2221,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
 	if (r == rdev) {
 		dev_err(dev, "Supply for %s (%s) resolved to itself\n",
 			rdev->desc->name, rdev->supply_name);
+		put_device(&rdev->dev);
 		if (!have_full_constraints()) {
 			ret = -EINVAL;
 			goto out;
-- 
2.34.1
Re: [PATCH] regulator: core: Fix rdev reference leak in regulator_resolve_supply()
Posted by Mark Brown 1 week ago
On Thu, 17 Sep 2026 14:28:10 +0000, Wentao Liang wrote:
> regulator: core: Fix rdev reference leak in regulator_resolve_supply()

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.4

Thanks!

[1/1] regulator: core: Fix rdev reference leak in regulator_resolve_supply()
      https://git.kernel.org/broonie/regulator/c/195bbe5e1c29

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark