* [PATCH] MIPS: CPC: Fix refcount leak in mips_cpc_default_phys_base
@ 2022-05-16 4:33 Miaoqian Lin
2022-05-23 9:18 ` Thomas Bogendoerfer
2022-05-23 13:16 ` Serge Semin
0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-05-16 4:33 UTC (permalink / raw)
To: Thomas Bogendoerfer, Miaoqian Lin, Geert Uytterhoeven,
Miodrag Dinic, James Hogan, Paul Burton, Aleksandar Markovic,
linux-mips, linux-kernel
of_find_compatible_node() returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
Add missing of_node_put() to avoid refcount leak.
Fixes: 791412dafbbf ("MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base()")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
arch/mips/kernel/mips-cpc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
index 17aff13cd7ce..3e386f7e1545 100644
--- a/arch/mips/kernel/mips-cpc.c
+++ b/arch/mips/kernel/mips-cpc.c
@@ -28,6 +28,7 @@ phys_addr_t __weak mips_cpc_default_phys_base(void)
cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc");
if (cpc_node) {
err = of_address_to_resource(cpc_node, 0, &res);
+ of_node_put(cpc_node);
if (!err)
return res.start;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: CPC: Fix refcount leak in mips_cpc_default_phys_base
2022-05-16 4:33 [PATCH] MIPS: CPC: Fix refcount leak in mips_cpc_default_phys_base Miaoqian Lin
@ 2022-05-23 9:18 ` Thomas Bogendoerfer
2022-05-23 13:16 ` Serge Semin
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2022-05-23 9:18 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Geert Uytterhoeven, Miodrag Dinic, James Hogan, Paul Burton,
Aleksandar Markovic, linux-mips, linux-kernel
On Mon, May 16, 2022 at 08:33:50AM +0400, Miaoqian Lin wrote:
> of_find_compatible_node() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when done.
> Add missing of_node_put() to avoid refcount leak.
>
> Fixes: 791412dafbbf ("MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base()")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> arch/mips/kernel/mips-cpc.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
> index 17aff13cd7ce..3e386f7e1545 100644
> --- a/arch/mips/kernel/mips-cpc.c
> +++ b/arch/mips/kernel/mips-cpc.c
> @@ -28,6 +28,7 @@ phys_addr_t __weak mips_cpc_default_phys_base(void)
> cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc");
> if (cpc_node) {
> err = of_address_to_resource(cpc_node, 0, &res);
> + of_node_put(cpc_node);
> if (!err)
> return res.start;
> }
> --
> 2.25.1
this is already fixed in mips-next.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: CPC: Fix refcount leak in mips_cpc_default_phys_base
2022-05-16 4:33 [PATCH] MIPS: CPC: Fix refcount leak in mips_cpc_default_phys_base Miaoqian Lin
2022-05-23 9:18 ` Thomas Bogendoerfer
@ 2022-05-23 13:16 ` Serge Semin
1 sibling, 0 replies; 3+ messages in thread
From: Serge Semin @ 2022-05-23 13:16 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Thomas Bogendoerfer, Geert Uytterhoeven, Miodrag Dinic,
James Hogan, Paul Burton, Aleksandar Markovic, linux-mips,
linux-kernel
On Mon, May 16, 2022 at 08:33:50AM +0400, Miaoqian Lin wrote:
> of_find_compatible_node() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when done.
> Add missing of_node_put() to avoid refcount leak.
>
> Fixes: 791412dafbbf ("MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base()")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Right. It's similar to the CDMM fix:
commit 4528668ca331 ("mips: cdmm: Fix refcount leak in mips_cdmm_phys_base")
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
-Sergey
> ---
> arch/mips/kernel/mips-cpc.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
> index 17aff13cd7ce..3e386f7e1545 100644
> --- a/arch/mips/kernel/mips-cpc.c
> +++ b/arch/mips/kernel/mips-cpc.c
> @@ -28,6 +28,7 @@ phys_addr_t __weak mips_cpc_default_phys_base(void)
> cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc");
> if (cpc_node) {
> err = of_address_to_resource(cpc_node, 0, &res);
> + of_node_put(cpc_node);
> if (!err)
> return res.start;
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-23 13:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 4:33 [PATCH] MIPS: CPC: Fix refcount leak in mips_cpc_default_phys_base Miaoqian Lin
2022-05-23 9:18 ` Thomas Bogendoerfer
2022-05-23 13:16 ` Serge Semin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.