lkml.org 
[lkml]   [2022]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] sparc: Fix reference leak in scan_of_devices
Date
of_find_node_by_path() returns a node pointer with
refcount incremented, we should use of_node_put() on it when not need
anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: cf44bbc26cf1 ("[SPARC]: Beginnings of generic of_device framework.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
arch/sparc/kernel/of_device_32.c | 4 +++-
arch/sparc/kernel/of_device_64.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c
index 4ebf51e6e78e..020b1c023d75 100644
--- a/arch/sparc/kernel/of_device_32.c
+++ b/arch/sparc/kernel/of_device_32.c
@@ -412,8 +412,10 @@ static int __init scan_of_devices(void)
struct platform_device *parent;

parent = scan_one_device(root, NULL);
- if (!parent)
+ if (!parent) {
+ of_node_put(root);
return 0;
+ }

scan_tree(root->child, &parent->dev);
return 0;
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 5a9f86b1d4e7..f044b4c1975b 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -705,8 +705,10 @@ static int __init scan_of_devices(void)
struct platform_device *parent;

parent = scan_one_device(root, NULL);
- if (!parent)
+ if (!parent) {
+ of_node_put(root);
return 0;
+ }

scan_tree(root->child, &parent->dev);
return 0;
--
2.25.1
\
 
 \ /
  Last update: 2022-06-07 05:35    [W:0.065 / U:3.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site