Skip to contentSkip to conversation

drm/bridge:tc358767: Add of_node_put() when breaking out of loop

PATCH In review Liang He 2 participants 2 messages Jul 7, 2022 – Jul 18, 2022

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 drm/bridge:tc358767: Add of_node_put() when breaking out of loop

In tc_probe_bridge_endpoint(), we should call of_node_put() when breaking out of the for_each_endpoint_of_node() which will automatically increase and decrease the refcount.

Fixes 71f7d9c03118 ("drm/bridge: tc358767: Detect bridge mode from connected endpoints in DT")
---
 drivers/gpu/drm/bridge/tc358767.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/tc358767.c +3 -1
index 485717c8f0b4..7362a1a7a7df 100644
@@ -1986,8 +1986,10 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc)
 
 	for_each_endpoint_of_node(dev->of_node, node) {
 		of_graph_parse_endpoint(node, &endpoint);
-		if (endpoint.port > 2)
+		if (endpoint.port > 2) {
+			of_node_put(node);
 			return -EINVAL;
+		}
 
 		mode |= BIT(endpoint.port);
 	}
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Can you use the norma commitl title prefix "drm/bridge: tc358767: "

Quoted 28 lines · Liang He

In tc_probe_bridge_endpoint(), we should call of_node_put() when breaking out of the for_each_endpoint_of_node() which will automatically increase and decrease the refcount.

Fixes 71f7d9c03118 ("drm/bridge: tc358767: Detect bridge mode from connected endpoints in DT")
---
 drivers/gpu/drm/bridge/tc358767.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/tc358767.c +3 -2
index 485717c8f0b4..7362a1a7a7df 100644
@@ -1986,8 +1986,10 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc)
 
        for_each_endpoint_of_node(dev->of_node, node) {
                of_graph_parse_endpoint(node, &endpoint);
-               if (endpoint.port > 2)
+               if (endpoint.port > 2) {
+                       of_node_put(node);
                        return -EINVAL;
+               }
 
                mode |= BIT(endpoint.port);
        }
--
Quoted 2 lines

2.25.1

Please resend a v2 with the above change.