public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mips/pic32/pic32mzda: Fix refcount leak bugs
@ 2022-06-19  4:54 Liang He
  2022-06-21 15:16 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-06-19  4:54 UTC (permalink / raw)
  To: tsbogend, yangtiezhu; +Cc: windhl, linux-mips, linux-kernel

of_find_matching_node(), of_find_compatible_node() and
of_find_node_by_path() will return node pointers with refcout
incremented. We should call of_node_put() when they are not
used anymore.

Signed-off-by: Liang He <windhl@126.com>
---
 changelog: 
 
 v2: (1) merge pic32/pic32mzda bugs into one patch
     (2) fix leak bug related to of_find_node_by_path.
 v1: use two patch for intit.c and time.c

 arch/mips/pic32/pic32mzda/init.c | 7 ++++++-
 arch/mips/pic32/pic32mzda/time.c | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/mips/pic32/pic32mzda/init.c b/arch/mips/pic32/pic32mzda/init.c
index 129915616763..d9c8c4e46aff 100644
--- a/arch/mips/pic32/pic32mzda/init.c
+++ b/arch/mips/pic32/pic32mzda/init.c
@@ -98,13 +98,18 @@ static int __init pic32_of_prepare_platform_data(struct of_dev_auxdata *lookup)
 		np = of_find_compatible_node(NULL, NULL, lookup->compatible);
 		if (np) {
 			lookup->name = (char *)np->name;
-			if (lookup->phys_addr)
+			if (lookup->phys_addr) {
+				of_node_put(np);
 				continue;
+			}
 			if (!of_address_to_resource(np, 0, &res))
 				lookup->phys_addr = res.start;
+			of_node_put(np);
 		}
 	}
 
+	of_node_put(root);
+
 	return 0;
 }
 
diff --git a/arch/mips/pic32/pic32mzda/time.c b/arch/mips/pic32/pic32mzda/time.c
index 7174e9abbb1b..777b515c52c8 100644
--- a/arch/mips/pic32/pic32mzda/time.c
+++ b/arch/mips/pic32/pic32mzda/time.c
@@ -32,6 +32,9 @@ static unsigned int pic32_xlate_core_timer_irq(void)
 		goto default_map;
 
 	irq = irq_of_parse_and_map(node, 0);
+
+	of_node_put(node);
+
 	if (!irq)
 		goto default_map;
 
-- 
2.25.1


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

* Re: [PATCH v2] mips/pic32/pic32mzda: Fix refcount leak bugs
  2022-06-19  4:54 [PATCH v2] mips/pic32/pic32mzda: Fix refcount leak bugs Liang He
@ 2022-06-21 15:16 ` Thomas Bogendoerfer
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2022-06-21 15:16 UTC (permalink / raw)
  To: Liang He; +Cc: yangtiezhu, linux-mips, linux-kernel

On Sun, Jun 19, 2022 at 12:54:27PM +0800, Liang He wrote:
> of_find_matching_node(), of_find_compatible_node() and
> of_find_node_by_path() will return node pointers with refcout
> incremented. We should call of_node_put() when they are not
> used anymore.
> 
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  changelog: 
>  
>  v2: (1) merge pic32/pic32mzda bugs into one patch
>      (2) fix leak bug related to of_find_node_by_path.
>  v1: use two patch for intit.c and time.c
> 
>  arch/mips/pic32/pic32mzda/init.c | 7 ++++++-
>  arch/mips/pic32/pic32mzda/time.c | 3 +++
>  2 files changed, 9 insertions(+), 1 deletion(-)

applied to mips-fixes.

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] 2+ messages in thread

end of thread, other threads:[~2022-06-21 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-19  4:54 [PATCH v2] mips/pic32/pic32mzda: Fix refcount leak bugs Liang He
2022-06-21 15:16 ` Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox