Skip to contentSkip to conversation

drm/bridge: anx7625: Fix refcount bug in anx7625_parse_dt()

PATCH Applied Liang He 2 participants 3 messages Jul 19, 2022

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH v2 1/2 drm/bridge: anx7625: Fix refcount bug in anx7625_parse_dt()

In anx7625_parse_dt(), 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")

---
changelog:

v2: (1) rebase with drm-misc-next advised by Robert Foss
(2) use proper title
(3) remove the v1's second bug ('ep0'), fixed recently
v1: https://lore.kernel.org/all/[email protected]/

 drivers/gpu/drm/bridge/analogix/anx7625.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +1 -0
index d1f1d525aeb6..79fc7a50b497 100644
@@ -1642,6 +1642,7 @@ static int anx7625_parse_dt(struct device *dev,
 	anx7625_get_swing_setting(dev, pdata);
 
 	pdata->is_dpi = 0; /* default dsi mode */
+	of_node_put(pdata->mipi_host_node);
 	pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
 	if (!pdata->mipi_host_node) {
 		DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 2/2 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")

---
changelog:

v2: (1) rebase with drm-misc-next advised by Robert Foss
(2) use proper title
v1: https://lore.kernel.org/all/[email protected]/

 drivers/gpu/drm/bridge/tc358767.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/tc358767.c +3 -2
index 02bd757a8987..1dc107f13645 100644
@@ -2010,9 +2010,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 v2 1/2 Applied
#2 lore raw
In reply to Liang He
Quoted 32 lines · Liang He

In anx7625_parse_dt(), 'pdata->mipi_host_node' will be assigned a new reference with of_graph_get_remote_node() which will increase the refcount of the object, correspondingly, we should call of_node_put() for the old reference stored in the 'pdata->mipi_host_node'.

Fixes 8bdfc5dae4e3 ("drm/bridge: anx7625: Add anx7625 MIPI DSI/DPI to DP")

---
changelog:

v2: (1) rebase with drm-misc-next advised by Robert Foss
(2) use proper title
(3) remove the v1's second bug ('ep0'), fixed recently
v1: https://lore.kernel.org/all/[email protected]/

 drivers/gpu/drm/bridge/analogix/anx7625.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/analogix/anx7625.c +1 -1
index d1f1d525aeb6..79fc7a50b497 100644
@@ -1642,6 +1642,7 @@ static int anx7625_parse_dt(struct device *dev,
        anx7625_get_swing_setting(dev, pdata);
 
        pdata->is_dpi = 0; /* default dsi mode */
+       of_node_put(pdata->mipi_host_node);
        pdata->mipi_host_node = of_graph_get_remote_node(np, 0, 0);
        if (!pdata->mipi_host_node) {
                DRM_DEV_ERROR(dev, "fail to get internal panel.\n");
--
Quoted 2 lines

2.25.1

This series has my r-b.

Applied series to drm-misc-next.