* [PATCH 4/4] regulator: tps6594: Fix device node reference leaks in multiphase loop
@ 2026-06-18 13:23 Uday Khare
2026-06-18 13:36 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Uday Khare @ 2026-06-18 13:23 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: linux-kernel, Uday Khare
In tps6594_regulator_probe(), the multi-phase configuration loop calls
of_find_node_by_name() to find buck nodes by name, and of_get_parent()
twice to navigate to the PMIC parent node. None of the acquired node
references (np, intermediate parent, np_pmic_parent) are ever released
via of_node_put(), causing a reference leak on every loop iteration.
Additionally, of_find_node_by_name() can return NULL, but the result was
immediately passed to of_node_full_name() and of_get_parent() without a
NULL check, which could lead to a NULL pointer dereference.
Fix this by:
- Adding a NULL check for np after of_find_node_by_name()
- Storing the intermediate parent node in a local variable np_parent
- Calling of_node_put() on np, np_parent and np_pmic_parent at the
end of each loop iteration
Fixes: f17ccc5deb4d ("regulator: tps6594-regulator: Add driver for TI TPS6594 regulators")
Signed-off-by: Uday Khare <udaykhare77@gmail.com>
---
drivers/regulator/tps6594-regulator.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/tps6594-regulator.c b/drivers/regulator/tps6594-regulator.c
index 645e83462c64..31a5218d5510 100644
--- a/drivers/regulator/tps6594-regulator.c
+++ b/drivers/regulator/tps6594-regulator.c
@@ -669,13 +669,20 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
* buck_configured to avoid creating bucks for every buck in multiphase
*/
for (multi = 0; multi < desc->num_multi_phase_regs; multi++) {
+ struct device_node *np_parent;
+
multi_regs = &desc->multi_phase_regs[multi];
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 (!np)
continue;
- if (strcmp(npname, multi_regs->supply_name) == 0) {
+
+ npname = of_node_full_name(np);
+ np_parent = of_get_parent(np);
+ np_pmic_parent = of_get_parent(np_parent);
+
+ if (np_pmic_parent &&
+ !of_node_cmp(of_node_full_name(np_pmic_parent), tps->dev->of_node->full_name) &&
+ strcmp(npname, multi_regs->supply_name) == 0) {
switch (multi) {
case MULTI_BUCK12:
buck_multi[0] = true;
@@ -706,6 +713,10 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
break;
}
}
+
+ of_node_put(np_pmic_parent);
+ of_node_put(np_parent);
+ of_node_put(np);
}
reg_irq_nb = desc->num_irq_types * (desc->num_buck_regs + desc->num_ldo_regs);
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 4/4] regulator: tps6594: Fix device node reference leaks in multiphase loop
2026-06-18 13:23 [PATCH 4/4] regulator: tps6594: Fix device node reference leaks in multiphase loop Uday Khare
@ 2026-06-18 13:36 ` Mark Brown
2026-06-18 14:17 ` Uday Khare
[not found] ` <CAFVYD-Hq+kfe2R28HhjMHboVjt6dZDf-85CJfvMfT6BdMVKdew@mail.gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2026-06-18 13:36 UTC (permalink / raw)
To: Uday Khare; +Cc: lgirdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 973 bytes --]
On Thu, Jun 18, 2026 at 06:53:27PM +0530, Uday Khare wrote:
> In tps6594_regulator_probe(), the multi-phase configuration loop calls
> of_find_node_by_name() to find buck nodes by name, and of_get_parent()
> twice to navigate to the PMIC parent node. None of the acquired node
> references (np, intermediate parent, np_pmic_parent) are ever released
> via of_node_put(), causing a reference leak on every loop iteration.
You've not copied me on the rest of the series so I don't know what's
going on with dependencies. When sending a patch series it is important
to ensure that all the various maintainers understand what the
relationship between the patches as the expecation is that there will be
interdependencies. Either copy everyone on the whole series or at least
copy them on the cover letter and explain what's going on. If there are
no strong interdependencies then it's generally simplest to just send
the patches separately to avoid any possible confusion.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 4/4] regulator: tps6594: Fix device node reference leaks in multiphase loop
2026-06-18 13:36 ` Mark Brown
@ 2026-06-18 14:17 ` Uday Khare
[not found] ` <CAFVYD-Hq+kfe2R28HhjMHboVjt6dZDf-85CJfvMfT6BdMVKdew@mail.gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: Uday Khare @ 2026-06-18 14:17 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, linux-kernel
Thank you for the feedback.
The 4 patches in this series fix independent resource leaks in 4
separate drivers across different subsystems (remoteproc, i2c, power
supply, and regulator). There are no interdependencies between them.
Each patch can be applied independently to its respective subsystem tree.
I sent them as a numbered series (1/4 through 4/4) for organizational
clarity, but they can be picked up separately.
Apologies for the confusion.
^ permalink raw reply [flat|nested] 4+ messages in thread[parent not found: <CAFVYD-Hq+kfe2R28HhjMHboVjt6dZDf-85CJfvMfT6BdMVKdew@mail.gmail.com>]
* Re: [PATCH 4/4] regulator: tps6594: Fix device node reference leaks in multiphase loop
[not found] ` <CAFVYD-Hq+kfe2R28HhjMHboVjt6dZDf-85CJfvMfT6BdMVKdew@mail.gmail.com>
@ 2026-06-18 16:33 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-06-18 16:33 UTC (permalink / raw)
To: Uday Khare; +Cc: lgirdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 768 bytes --]
On Thu, Jun 18, 2026 at 07:41:07PM +0530, Uday Khare wrote:
> Thank you for the feedback.
>
> The 4 patches in this series fix independent resource leaks in 4
> separate drivers across different subsystems (remoteproc, i2c, power
> supply, and regulator). There are no interdependencies between them.
> Each patch can be applied independently to its respective subsystem tree.
>
> I sent them as a numbered series (1/4 through 4/4) for organizational
> clarity, but they can be picked up separately.
I see. Doing that actually makes things less clear since normally
things sent in a series need to be applied together and if things cross
subsystems that needs coordination. If there are no dependencies then
you should send a series per subsystem.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-18 16:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-18 13:23 [PATCH 4/4] regulator: tps6594: Fix device node reference leaks in multiphase loop Uday Khare
2026-06-18 13:36 ` Mark Brown
2026-06-18 14:17 ` Uday Khare
[not found] ` <CAFVYD-Hq+kfe2R28HhjMHboVjt6dZDf-85CJfvMfT6BdMVKdew@mail.gmail.com>
2026-06-18 16:33 ` Mark Brown
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®