* [PATCH] cache: ax45mp: Fix device node reference leak in ax45mp_cache_init()
@ 2026-01-30 17:49 Felix Gu
2026-02-06 20:28 ` Conor Dooley
0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-01-30 17:49 UTC (permalink / raw)
To: Conor Dooley, Jonathan Cameron, Lad Prabhakar, Palmer Dabbelt
Cc: Conor Dooley, linux-kernel, Felix Gu
In ax45mp_cache_init(), of_find_matching_node() returns a device node
with an incremented reference count that must be released with
of_node_put(). The current code fails to call of_node_put() which
causes a reference leak.
Use the __free(device_node) attribute to ensure automatic cleanup when
the variable goes out of scope.
Fixes: d34599bcd2e4 ("cache: Add L2 cache management for Andes AX45MP RISC-V core")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/cache/ax45mp_cache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cache/ax45mp_cache.c b/drivers/cache/ax45mp_cache.c
index 1d7dd3d2c101..934c5087ec2b 100644
--- a/drivers/cache/ax45mp_cache.c
+++ b/drivers/cache/ax45mp_cache.c
@@ -178,11 +178,11 @@ static const struct of_device_id ax45mp_cache_ids[] = {
static int __init ax45mp_cache_init(void)
{
- struct device_node *np;
struct resource res;
int ret;
- np = of_find_matching_node(NULL, ax45mp_cache_ids);
+ struct device_node *np __free(device_node) =
+ of_find_matching_node(NULL, ax45mp_cache_ids);
if (!of_device_is_available(np))
return -ENODEV;
---
base-commit: 33a647c659ffa5bdb94abc345c8c86768ff96215
change-id: 20260131-ax45mp-3604ec76f878
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] cache: ax45mp: Fix device node reference leak in ax45mp_cache_init()
2026-01-30 17:49 [PATCH] cache: ax45mp: Fix device node reference leak in ax45mp_cache_init() Felix Gu
@ 2026-02-06 20:28 ` Conor Dooley
0 siblings, 0 replies; 2+ messages in thread
From: Conor Dooley @ 2026-02-06 20:28 UTC (permalink / raw)
To: linux-riscv, Conor Dooley, Jonathan Cameron, Lad Prabhakar,
Palmer Dabbelt, Felix Gu
Cc: Conor Dooley, Daire McNamara, Rob Herring, Krzysztof Kozlowski,
devicetree, linux-kernel
From: Conor Dooley <conor.dooley@microchip.com>
On Sat, 31 Jan 2026 01:49:09 +0800, Felix Gu wrote:
> In ax45mp_cache_init(), of_find_matching_node() returns a device node
> with an incremented reference count that must be released with
> of_node_put(). The current code fails to call of_node_put() which
> causes a reference leak.
>
> Use the __free(device_node) attribute to ensure automatic cleanup when
> the variable goes out of scope.
>
> [...]
Applied to riscv-soc-fixes, thanks!
[1/1] cache: ax45mp: Fix device node reference leak in ax45mp_cache_init()
https://git.kernel.org/conor/c/0528a348b04b
Thanks,
Conor.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-06 20:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-30 17:49 [PATCH] cache: ax45mp: Fix device node reference leak in ax45mp_cache_init() Felix Gu
2026-02-06 20:28 ` Conor Dooley
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®