Skip to contentSkip to conversation

drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()

PATCH Applied Liang He 2 participants 3 messages Jul 26, 2022 – Aug 8, 2022

Subsystems (4)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()

In this function, there are two refcount leak bugs:
(1) when breaking out of for_each_endpoint_of_node(), we need call the of_node_put() for the 'ep';
(2) we should call of_node_put() for the reference returned by of_graph_get_remote_port() when it is not used anymore.

Fixes bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
---
 drivers/gpu/drm/meson/meson_drv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_drv.c +4 -1
index 1b70938cfd2c..bd4ca11d3ff5 100644
@@ -115,8 +115,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
 	for_each_endpoint_of_node(dev->of_node, ep) {
 		/* If the endpoint node exists, consider it enabled */
 		remote = of_graph_get_remote_port(ep);
-		if (remote)
+		if (remote) {
+			of_node_put(remote);
+			of_node_put(ep);
 			return true;
+		}
 	}
 
 	return false;
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Liang He

In this function, there are two refcount leak bugs:
(1) when breaking out of for_each_endpoint_of_node(), we need call the of_node_put() for the 'ep';
(2) we should call of_node_put() for the reference returned by of_graph_get_remote_port() when it is not used anymore.

Fixes bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
---
  drivers/gpu/drm/meson/meson_drv.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/meson/meson_drv.c +0 -0
index 1b70938cfd2c..bd4ca11d3ff5 100644
@@ -115,8 +115,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
  	for_each_endpoint_of_node(dev->of_node, ep) {
  		/* If the endpoint node exists, consider it enabled */

drivers/gpu/drm/meson/meson_drv.c static bool meson_vpu_has_available_connectors(struct device *dev) · line 125

Quoted 10 lines
drivers/gpu/drm/meson/meson_drv.c +4 -1
  		remote = of_graph_get_remote_port(ep);
-		if (remote)
+		if (remote) {
+			of_node_put(remote);
+			of_node_put(ep);
  			return true;
+		}
  	}
 
  	return false;

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#2 lore raw
In reply to Liang He

Hi,

Quoted 8 lines · Liang He

In this function, there are two refcount leak bugs:
(1) when breaking out of for_each_endpoint_of_node(), we need call the of_node_put() for the 'ep';
(2) we should call of_node_put() for the reference returned by of_graph_get_remote_port() when it is not used anymore.

[...]

Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-fixes)

[1/1] drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()

      https://cgit.freedesktop.org/drm/drm-misc/commit/?id=91b3c8dbe898df158fd2a84675f3a284ff6666f7
Signature · 6 lines
Neil

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic