[PATCH v2] bus/ti-sys: Fix refcount leak bugs

Liang He
2022-06-20T15:11:21Z

In sysc_init_stdout_path(), there is only one of_node_put() for the
second of_find_node_by_path(). However, we need to add one of_node_put()
for the first of_find_node_by_path().

In sysc_init_static_data(), we need one of_node_put() for the
of_find_node_by_path() to keep refcount balance.

Signed-off-by: Liang He <windhl@126.com>
---
changelog:

v2: merge two bugs into one commit
v1: only find the bug in sysc_init_static_data()

drivers/bus/ti-sysc.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index 9a7d12332fad..85a1003eb8e2 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -751,6 +751,7 @@ static void sysc_init_stdout_path(struct sysc *ddata)
goto err;

uart = of_get_property(np, "stdout-path", NULL);
+ of_node_put(np);
if (!uart)
goto err;

@@ -3138,6 +3139,7 @@ static int sysc_init_static_data(struct sysc *ddata)
np = of_find_node_by_path("/ocp");
WARN_ONCE(np && of_device_is_compatible(np, "simple-bus"),
"ti-sysc: Incomplete old dtb, please update\n");
+ of_node_put(np);
break;
default:
break;
--
2.25.1