Skip to contentSkip to conversation

drm/mediatek: Fix device node reference leak in mtk_dp_dt_parse()

PATCH In review Miaoqian Lin 3 participants 3 messages Oct 29, 2025 – Nov 19, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/mediatek: Fix device node reference leak in mtk_dp_dt_parse()

The function mtk_dp_dt_parse() calls of_graph_get_endpoint_by_regs() to get the endpoint device node, but fails to call of_node_put() to release the reference when the function returns. This results in a device node reference leak.

Fix this by adding the missing of_node_put() call before returning from the function.

Found via static analysis and code review.

Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")
---
 drivers/gpu/drm/mediatek/mtk_dp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/mediatek/mtk_dp.c +1 -0
index bef6eeb30d3e..b0b1e158600f 100644
@@ -2087,6 +2087,7 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
 	endpoint = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 1, -1);
 	len = of_property_count_elems_of_size(endpoint,
 					      "data-lanes", sizeof(u32));
+	of_node_put(endpoint);
 	if (len < 0 || len > 4 || len == 3) {
 		dev_err(dev, "invalid data lane size: %d\n", len);
 		return -EINVAL;
Signature · 1 line
2.39.5 (Apple Git-154)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Miaoqian Lin

The function mtk_dp_dt_parse() calls of_graph_get_endpoint_by_regs() to get the endpoint device node, but fails to call of_node_put() to release the reference when the function returns. This results in a device node reference leak.

Quoted 8 lines

Fix this by adding the missing of_node_put() call before returning from the function.

Found via static analysis and code review.

Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")

Best
Markus

Reviewed-by on v1 1/1
#2 lore raw
In reply to Miaoqian Lin
Quoted 8 lines · Miaoqian Lin

External email : Please do not click links or open attachments until you have verified the sender or the content.

The function mtk_dp_dt_parse() calls of_graph_get_endpoint_by_regs() to get the endpoint device node, but fails to call of_node_put() to release the reference when the function returns. This results in a device node reference leak.

Quoted 4 lines

Fix this by adding the missing of_node_put() call before returning from the function.

Found via static analysis and code review.

Quoted 23 lines
Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")
---
 drivers/gpu/drm/mediatek/mtk_dp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/mediatek/mtk_dp.c +1 -1
index bef6eeb30d3e..b0b1e158600f 100644
@@ -2087,6 +2087,7 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
        endpoint = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 1, -1);
        len = of_property_count_elems_of_size(endpoint,
                                              "data-lanes", sizeof(u32));
+       of_node_put(endpoint);
        if (len < 0 || len > 4 || len == 3) {
                dev_err(dev, "invalid data lane size: %d\n", len);
                return -EINVAL;
--

2.39.5 (Apple Git-154)