* [PATCH v1] ARM: OMAP2+: Fix OF node reference leaks in omap_hwmod
@ 2026-05-04 16:47 Yuho Choi
2026-06-03 2:54 ` 최유호
2026-06-07 5:52 ` Andreas Kemnade
0 siblings, 2 replies; 3+ messages in thread
From: Yuho Choi @ 2026-05-04 16:47 UTC (permalink / raw)
To: Paul Walmsley, Aaro Koskinen, Andreas Kemnade, Kevin Hilman,
Roger Quadros, Tony Lindgren, Russell King
Cc: linux-omap, linux-arm-kernel, linux-kernel, Yuho Choi
The OF helpers that return device nodes acquire references that must be
released by the caller.
_init() leaks the "ocp" bus node returned by of_find_node_by_name() on
all paths after lookup, and also leaks the child returned by
of_get_next_child() when parsing module flags. Route the post-lookup
returns through a common cleanup path and release the child after use.
omap_hwmod_setup_earlycon_flags() leaks the /chosen node and the UART
node resolved from stdout-path. Track them separately and drop both
references after use.
Fixes: 1aa8f0cb19e5 ("ARM: OMAP2+: Remove unused legacy code for interconnects")
Fixes: 4f2122473363 ("ARM: OMAP2+: Check also the first dts child for hwmod flags")
Fixes: 8dd6666f4937 ("ARM: OMAP2+: omap_hwmod: Add support for earlycon")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
arch/arm/mach-omap2/omap_hwmod.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 974107ff18b4..03cd523dff87 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2331,13 +2331,15 @@ static int __init _init(struct omap_hwmod *oh, void *data)
if (r < 0) {
WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n",
oh->name);
- return 0;
+ r = 0;
+ goto out_put_node;
}
r = _init_clocks(oh, np);
if (r < 0) {
WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
- return -EINVAL;
+ r = -EINVAL;
+ goto out_put_node;
}
if (np) {
@@ -2345,13 +2347,19 @@ static int __init _init(struct omap_hwmod *oh, void *data)
parse_module_flags(oh, np);
child = of_get_next_child(np, NULL);
- if (child)
+ if (child) {
parse_module_flags(oh, child);
+ of_node_put(child);
+ }
}
oh->_state = _HWMOD_STATE_INITIALIZED;
- return 0;
+ r = 0;
+
+out_put_node:
+ of_node_put(bus);
+ return r;
}
/**
@@ -3608,13 +3616,13 @@ int omap_hwmod_init_module(struct device *dev,
#ifdef CONFIG_SERIAL_EARLYCON
static void __init omap_hwmod_setup_earlycon_flags(void)
{
- struct device_node *np;
+ struct device_node *np, *chosen;
struct omap_hwmod *oh;
const char *uart;
- np = of_find_node_by_path("/chosen");
- if (np) {
- uart = of_get_property(np, "stdout-path", NULL);
+ chosen = of_find_node_by_path("/chosen");
+ if (chosen) {
+ uart = of_get_property(chosen, "stdout-path", NULL);
if (uart) {
np = of_find_node_by_path(uart);
if (np) {
@@ -3629,8 +3637,10 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
if (oh)
oh->flags |= DEBUG_OMAPUART_FLAGS;
}
+ of_node_put(np);
}
}
+ of_node_put(chosen);
}
#endif
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1] ARM: OMAP2+: Fix OF node reference leaks in omap_hwmod
2026-05-04 16:47 [PATCH v1] ARM: OMAP2+: Fix OF node reference leaks in omap_hwmod Yuho Choi
@ 2026-06-03 2:54 ` 최유호
2026-06-07 5:52 ` Andreas Kemnade
1 sibling, 0 replies; 3+ messages in thread
From: 최유호 @ 2026-06-03 2:54 UTC (permalink / raw)
To: Paul Walmsley, Aaro Koskinen, Andreas Kemnade, Kevin Hilman,
Roger Quadros, Tony Lindgren, Russell King
Cc: linux-omap, linux-arm-kernel, linux-kernel
Hi,
Just a gentle reminder regarding this patch.
I would appreciate any feedback when you have a chance to review it.
Thanks for your time.
Best regards,
Yuho Choi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] ARM: OMAP2+: Fix OF node reference leaks in omap_hwmod
2026-05-04 16:47 [PATCH v1] ARM: OMAP2+: Fix OF node reference leaks in omap_hwmod Yuho Choi
2026-06-03 2:54 ` 최유호
@ 2026-06-07 5:52 ` Andreas Kemnade
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Kemnade @ 2026-06-07 5:52 UTC (permalink / raw)
To: Yuho Choi
Cc: Paul Walmsley, Aaro Koskinen, Kevin Hilman, Roger Quadros,
Tony Lindgren, Russell King, linux-omap, linux-arm-kernel,
linux-kernel
On Mon, 4 May 2026 12:47:11 -0400
Yuho Choi <dbgh9129@gmail.com> wrote:
> The OF helpers that return device nodes acquire references that must be
> released by the caller.
>
> _init() leaks the "ocp" bus node returned by of_find_node_by_name() on
> all paths after lookup, and also leaks the child returned by
> of_get_next_child() when parsing module flags. Route the post-lookup
> returns through a common cleanup path and release the child after use.
>
> omap_hwmod_setup_earlycon_flags() leaks the /chosen node and the UART
> node resolved from stdout-path. Track them separately and drop both
> references after use.
>
> Fixes: 1aa8f0cb19e5 ("ARM: OMAP2+: Remove unused legacy code for interconnects")
> Fixes: 4f2122473363 ("ARM: OMAP2+: Check also the first dts child for hwmod flags")
> Fixes: 8dd6666f4937 ("ARM: OMAP2+: omap_hwmod: Add support for earlycon")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Reviewed-by: Andreas Kemnade <andreas@kemnade.info>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-07 5:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 16:47 [PATCH v1] ARM: OMAP2+: Fix OF node reference leaks in omap_hwmod Yuho Choi
2026-06-03 2:54 ` 최유호
2026-06-07 5:52 ` Andreas Kemnade
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox