mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe()
@ 2026-09-17 14:31 Wentao Liang
  2026-09-17 22:21 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Wentao Liang @ 2026-09-17 14:31 UTC (permalink / raw)
  To: broonie; +Cc: eblanc, jneanne, lgirdwood, linux-kernel, Wentao Liang, stable

tps6594_regulator_probe() takes a reference on the PMIC parent node
with of_get_parent(), but never drops it, so the reference leaks on
every loop iteration and on each error return of the probe.

Release the reference after its last use.

Fixes: f17ccc5deb4d ("regulator: tps6594-regulator: Add driver for TI TPS6594 regulators")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/regulator/tps6594-regulator.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/tps6594-regulator.c b/drivers/regulator/tps6594-regulator.c
index 645e83462c64..e0ae2cac0b66 100644
--- a/drivers/regulator/tps6594-regulator.c
+++ b/drivers/regulator/tps6594-regulator.c
@@ -673,8 +673,10 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
 		np = of_find_node_by_name(tps->dev->of_node, multi_regs->supply_name);
 		npname = of_node_full_name(np);
 		np_pmic_parent = of_get_parent(of_get_parent(np));
-		if (of_node_cmp(of_node_full_name(np_pmic_parent), tps->dev->of_node->full_name))
+		if (of_node_cmp(of_node_full_name(np_pmic_parent), tps->dev->of_node->full_name)) {
+			of_node_put(np_pmic_parent);
 			continue;
+		}
 		if (strcmp(npname, multi_regs->supply_name) == 0) {
 			switch (multi) {
 			case MULTI_BUCK12:
@@ -706,6 +708,8 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
 				break;
 			}
 		}
+
+		of_node_put(np_pmic_parent);
 	}
 
 	reg_irq_nb = desc->num_irq_types * (desc->num_buck_regs + desc->num_ldo_regs);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe()
  2026-09-17 14:31 [PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe() Wentao Liang
@ 2026-09-17 22:21 ` Mark Brown
  2026-11-07  7:00   ` Wentao Liang
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-09-17 22:21 UTC (permalink / raw)
  To: Wentao Liang; +Cc: eblanc, jneanne, lgirdwood, linux-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 331 bytes --]

On Thu, Sep 17, 2026 at 02:31:55PM +0000, Wentao Liang wrote:
> tps6594_regulator_probe() takes a reference on the PMIC parent node
> with of_get_parent(), but never drops it, so the reference leaks on
> every loop iteration and on each error return of the probe.

This doesn't apply against current code, please check and resend.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe()
  2026-09-17 22:21 ` Mark Brown
@ 2026-11-07  7:00   ` Wentao Liang
  0 siblings, 0 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-07  7:00 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-regulator, linux-kernel

On Thu, Sep 17, 2026 at 11:21:42PM +0100, Mark Brown wrote:
> This doesn't apply against current code, please check and resend.

Sorry for the very late reply, and for not checking the patch against
current code before sending it.

The reason it does not apply is that the leak has already been fixed by

  7fd28093b3ef ("regulator: tps6594: Fix device node reference leaks in multiphase loop")

which releases np, the intermediate parent and np_pmic_parent at the end
of each iteration, and adds the missing NULL check after
of_find_node_by_name() as well.  The commit is in v7.3-rc1 and later, and
I confirmed that current mainline has no unbalanced of_get_parent() left
in that loop.

So there is nothing to resend from my side, and I will not submit a
duplicate.  Sorry again for the delay and for the noise.

Thanks,
Wentao


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-07 14:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 14:31 [PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe() Wentao Liang
2026-09-17 22:21 ` Mark Brown
2026-11-07  7:00   ` Wentao Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®