[PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe()

Wentao Liang posted 1 patch 1 week ago
drivers/regulator/tps6594-regulator.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe()
Posted by Wentao Liang 1 week ago
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
Re: [PATCH] regulator: tps6594-regulator: Fix np_pmic_parent leak in tps6594_regulator_probe()
Posted by Mark Brown 1 week ago
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.