mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] ARM: Feroceon: Fix OF node and mapping leaks in L2 init
@ 2026-05-05  0:32 Yuho Choi
  2026-06-03  2:52 ` 최유호
  0 siblings, 1 reply; 3+ messages in thread
From: Yuho Choi @ 2026-05-05  0:32 UTC (permalink / raw)
  To: Russell King, Nishanth Menon
  Cc: Lee Jones, Kees Cook, linux-arm-kernel, linux-kernel, Yuho Choi

of_find_matching_node() returns a referenced device node, and of_iomap()
creates a temporary mapping. feroceon_of_init() currently leaves both
resources around after init and also returns from the of_iomap() failure
path without dropping the node reference.

Unmap the register mapping after the register update and put the node on
both the failure and success paths.

Fixes: 4b8f7a11c9fb ("ARM: MM: Add DT binding for Feroceon L2 cache")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 arch/arm/mm/cache-feroceon-l2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c
index 2bfefb252ffd..1fe931a09d79 100644
--- a/arch/arm/mm/cache-feroceon-l2.c
+++ b/arch/arm/mm/cache-feroceon-l2.c
@@ -373,16 +373,20 @@ int __init feroceon_of_init(void)
 	node = of_find_matching_node(NULL, feroceon_ids);
 	if (node && of_device_is_compatible(node, "marvell,kirkwood-cache")) {
 		base = of_iomap(node, 0);
-		if (!base)
+		if (!base) {
+			of_node_put(node);
 			return -ENOMEM;
+		}
 
 		if (l2_wt_override)
 			writel(readl(base) | L2_WRITETHROUGH_KIRKWOOD, base);
 		else
 			writel(readl(base) & ~L2_WRITETHROUGH_KIRKWOOD, base);
+		iounmap(base);
 	}
 
 	feroceon_l2_init(l2_wt_override);
+	of_node_put(node);
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] ARM: Feroceon: Fix OF node and mapping leaks in L2 init
  2026-05-05  0:32 [PATCH v1] ARM: Feroceon: Fix OF node and mapping leaks in L2 init Yuho Choi
@ 2026-06-03  2:52 ` 최유호
  2026-06-03  3:05   ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: 최유호 @ 2026-06-03  2:52 UTC (permalink / raw)
  To: Russell King, Nishanth Menon
  Cc: Lee Jones, Kees Cook, 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

On Mon, 4 May 2026 at 20:32, Yuho Choi <dbgh9129@gmail.com> wrote:
>
> of_find_matching_node() returns a referenced device node, and of_iomap()
> creates a temporary mapping. feroceon_of_init() currently leaves both
> resources around after init and also returns from the of_iomap() failure
> path without dropping the node reference.
>
> Unmap the register mapping after the register update and put the node on
> both the failure and success paths.
>
> Fixes: 4b8f7a11c9fb ("ARM: MM: Add DT binding for Feroceon L2 cache")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
>  arch/arm/mm/cache-feroceon-l2.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c
> index 2bfefb252ffd..1fe931a09d79 100644
> --- a/arch/arm/mm/cache-feroceon-l2.c
> +++ b/arch/arm/mm/cache-feroceon-l2.c
> @@ -373,16 +373,20 @@ int __init feroceon_of_init(void)
>         node = of_find_matching_node(NULL, feroceon_ids);
>         if (node && of_device_is_compatible(node, "marvell,kirkwood-cache")) {
>                 base = of_iomap(node, 0);
> -               if (!base)
> +               if (!base) {
> +                       of_node_put(node);
>                         return -ENOMEM;
> +               }
>
>                 if (l2_wt_override)
>                         writel(readl(base) | L2_WRITETHROUGH_KIRKWOOD, base);
>                 else
>                         writel(readl(base) & ~L2_WRITETHROUGH_KIRKWOOD, base);
> +               iounmap(base);
>         }
>
>         feroceon_l2_init(l2_wt_override);
> +       of_node_put(node);
>
>         return 0;
>  }
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] ARM: Feroceon: Fix OF node and mapping leaks in L2 init
  2026-06-03  2:52 ` 최유호
@ 2026-06-03  3:05   ` Andrew Lunn
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2026-06-03  3:05 UTC (permalink / raw)
  To: 최유호
  Cc: Russell King, Nishanth Menon, Lee Jones, Kees Cook,
	linux-arm-kernel, linux-kernel

On Tue, Jun 02, 2026 at 10:52:32PM -0400, 최유호 wrote:
> Hi,
> 
> Just a gentle reminder regarding this patch.
> 
> I would appreciate any feedback when you have a chance to review it.

What do you think happens to the machine if it cannot enable L2?  I
think you have much bigger problems than some minor resource leaks.

Please read

https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

Does this patch fulfil those rules. Please could you point to bug
reports of the leaked resources, so we know it actually bothers
people.

	Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-03  3:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-05  0:32 [PATCH v1] ARM: Feroceon: Fix OF node and mapping leaks in L2 init Yuho Choi
2026-06-03  2:52 ` 최유호
2026-06-03  3:05   ` Andrew Lunn

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®