Re: [PATCH] spmi: pmic-arb: Fix OF node leak in spmi_pmic_arb_register_buses()
From: Fenglin Wu
Date: Fri Jun 05 2026 - 03:57:58 EST
On 6/5/2026 2:15 PM, Jie Gan wrote:
On 6/5/2026 1:46 PM, Fenglin Wu wrote:
Call of_node_put(child) to reduce its reference count when
bailing out from the for_each_available_child_of_node() loop
upon an error in bus registration.
Also, return 0 directly if there are no errors in bus
registration.
Fixes: 979987371739 ("spmi: pmic-arb: Add multi bus support")
Signed-off-by: Fenglin Wu <fenglin.wu@xxxxxxxxxxxxxxxx>
---
drivers/spmi/spmi-pmic-arb.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 2e2cb4774103..26e804ad95a1 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -2055,12 +2055,14 @@ static int spmi_pmic_arb_register_buses(struct spmi_pmic_arb *pmic_arb,
for_each_available_child_of_node_scoped(node, child) {
if (of_node_name_eq(child, "spmi")) {
ret = spmi_pmic_arb_bus_init(pdev, child, pmic_arb);
- if (ret)
+ if (ret) {
+ of_node_put(child);
We dont need of_node_put here. The for_each_available_child_of_node_scoped will handle the refcnt automatically.
Thanks,
Jie
Ahh, thanks for pointing out. Just trying to send a patch which was applied in our downstream code base. I didn't notice this was fixed on the tip.
Anyway, still need to fix the minor one on the "ret" value initialization. Will resend.
return ret;
+ }
}
}
- return ret;
+ return 0;
}
static void spmi_pmic_arb_deregister_buses(struct spmi_pmic_arb *pmic_arb)
---
base-commit: 3443eec9c55d128064c83225a9111f1a1a37277a
change-id: 20260604-spmi-bus-register-fix-dfdb94bf834e
Best regards,
--
Fenglin Wu <fenglin.wu@xxxxxxxxxxxxxxxx>