* [PATCH v1] bus: mvebu-mbus: Fix OF node reference leaks in DT init
@ 2026-06-15 19:12 Yuho Choi
0 siblings, 0 replies; only message in thread
From: Yuho Choi @ 2026-06-15 19:12 UTC (permalink / raw)
To: Andrew Lunn, Sebastian Hesselbarth, Gregory Clement
Cc: linux-arm-kernel, linux-kernel, Yuho Choi
mvebu_mbus_dt_init() gets the MBUS node with
of_find_matching_node_and_match() and the controller node with
of_find_node_by_phandle(). Both helpers return nodes with incremented
references, but the function returns without dropping either reference.
Route the error and success paths through common cleanup labels so both
local node references are released once they are no longer needed.
Fixes: 6839cfa82f99 ("bus: mvebu-mbus: Introduce device tree binding")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
drivers/bus/mvebu-mbus.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index dd94145c9b22..61301beeecdc 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -1265,23 +1265,27 @@ int __init mvebu_mbus_dt_init(bool is_coherent)
prop = of_get_property(np, "controller", NULL);
if (!prop) {
pr_err("required 'controller' property missing\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto put_np;
}
controller = of_find_node_by_phandle(be32_to_cpup(prop));
if (!controller) {
pr_err("could not find an 'mbus-controller' node\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto put_np;
}
if (of_address_to_resource(controller, 0, &mbuswins_res)) {
pr_err("cannot get MBUS register address\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto put_controller;
}
if (of_address_to_resource(controller, 1, &sdramwins_res)) {
pr_err("cannot get SDRAM register address\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto put_controller;
}
/*
@@ -1312,9 +1316,15 @@ int __init mvebu_mbus_dt_init(bool is_coherent)
resource_size(&mbusbridge_res),
is_coherent);
if (ret)
- return ret;
+ goto put_controller;
/* Setup statically declared windows in the DT */
- return mbus_dt_setup(&mbus_state, np);
+ ret = mbus_dt_setup(&mbus_state, np);
+
+put_controller:
+ of_node_put(controller);
+put_np:
+ of_node_put(np);
+ return ret;
}
#endif
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-15 19:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 19:12 [PATCH v1] bus: mvebu-mbus: Fix OF node reference leaks in DT init Yuho Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox