The function rockchip_drm_encoder_set_crtc_endpoint_id() acquires device tree node references via of_graph_get_endpoint_by_regs() and of_graph_get_remote_endpoint(), but never releases them. This happens on all exit paths, including the success path.
This leads to reference count leaks that accumulate during encoder probe. In deferred probe scenarios or module reload, the leaked references can cause of_node_get() to eventually return -ENOMEM, breaking subsequent device tree parsing. Fix by adding the corresponding of_node_put() calls for both 'en' and 'ren', and use a unified error path to avoid duplication. Signed-off-by: Jiaqi <[email protected]> --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 14 +++++++++---- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 8afabe2118a9..1234567890ab 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -278,18 +278,22 @@ int rockchip_drm_encoder_set_crtc_endpoint_id(struct rockchip_encoder *rkencoder, { struct of_endpoint ep; struct device_node *en, *ren; int ret; en = of_graph_get_endpoint_by_regs(np, port, reg); if (!en) return -ENOENT; ren = of_graph_get_remote_endpoint(en); if (!ren) - return -ENOENT; + goto err_put_en; ret = of_graph_parse_endpoint(ren, &ep); if (ret) - return ret; + goto err_put_ren; rkencoder->crtc_endpoint_id = ep.id; - return 0; +err_put_ren: + of_node_put(ren); +err_put_en: + of_node_put(en); + return ret; } /* -- 2.40.0
