Skip to contentSkip to conversation

bus/ti-sys: Fix refcount leak bugs

PATCH In review Liang He 2 participants 6 messages Jun 20, 2022 – Jul 4, 2022 OMAP2+ support

lore
Share & tools
lore

Liang He

author
#0 lore raw

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

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.

---
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(+)
drivers/bus/ti-sysc.c +2 -0
index 9a7d12332fad..85a1003eb8e2 100644
@@ -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;
Signature · 1 line
2.25.1
maintainer
#1 lore raw

drivers/bus/ti-sysc.c static void sysc_init_stdout_path(struct sysc *ddata) · line 757

Quoted 10 lines · Liang He
drivers/bus/ti-sysc.c +1 -0
@@ -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;
 

Looks like you missed another of_node_put() after of_find_node_by_path() in sysc_init_stdout_path(). Please add it and repost.

Thanks,

Tony

author
#2 lore raw
Quoted 15 lines · Tony Lindgren

drivers/bus/ti-sysc.c static void sysc_init_stdout_path(struct sysc *ddata) · line 757

Quoted 10 lines · Liang He
drivers/bus/ti-sysc.c +1 -0
@@ -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;
 

Looks like you missed another of_node_put() after of_find_node_by_path() in sysc_init_stdout_path(). Please add it and repost.

Quoted 3 lines

Thanks,

Tony

Thanks, I will resend a new patch soon.

author
#3 lore raw
Quoted 19 lines · Liang He
Quoted 15 lines · Tony Lindgren

drivers/bus/ti-sysc.c static void sysc_init_stdout_path(struct sysc *ddata) · line 757

Quoted 10 lines · Liang He
drivers/bus/ti-sysc.c +1 -0
@@ -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;
 

Looks like you missed another of_node_put() after of_find_node_by_path() in sysc_init_stdout_path(). Please add it and repost.

Quoted 6 lines
Quoted 3 lines

Thanks,

Tony

Thanks, I will resend a new patch soon.

Sorry, Tony.

I have re-checked the sysc_init_stdout_path(), I think the second of_node_put is not needed as the second 'np' will be escaped out into global 'stdout_path'.

If my understanding is wrong, please correct me.

Thanks.
Liang

maintainer
#4 lore raw
Quoted 2 lines · Liang He

I have re-checked the sysc_init_stdout_path(), I think the second of_node_put is not needed as the second 'np' will be escaped out into global 'stdout_path'.

Yup you're right, thanks for checking it.

Regards,

Tony

maintainer
#5 lore raw
Quoted 5 lines · Tony Lindgren
Quoted 2 lines · Liang He

I have re-checked the sysc_init_stdout_path(), I think the second of_node_put is not needed as the second 'np' will be escaped out into global 'stdout_path'.

Yup you're right, thanks for checking it.

Applying into omap-for-v5.20/ti-sysc thanks.

Tony