[PATCH v2 1/2] drm/rockchip: vop2: Clean up after a failed vop2_create_crtcs()

Arun Iyengar via B4 Relay devnull+aiyengar1990.gmail.com at kernel.org
Tue Dec 1 02:28:05 PST 2026


From: Arun Iyengar <aiyengar1990 at gmail.com>

vop2_create_crtcs() returns errors without dropping the port nodes or
the planes and CRTCs it registered. component_bind() then frees struct
vop2 and rockchip_drm_bind() unwinds through drm_mode_config_cleanup()
on the freed planes and CRTCs. The RK3576 interrupt setup after it does
the same.

Call vop2_destroy_crtcs() on these errors and drop every port node
there, not only those of initialised CRTCs.

Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver")
Reported-by: Sashiko <sashiko-bot at kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-226823@kernel.org/
Signed-off-by: Arun Iyengar <aiyengar1990 at gmail.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 76d151b8bc52b..bbe86aecf9039 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -2757,18 +2757,20 @@ static void vop2_destroy_crtcs(struct vop2 *vop2)
 	struct list_head *plane_list = &drm->mode_config.plane_list;
 	struct drm_crtc *crtc, *tmpc;
 	struct drm_plane *plane, *tmpp;
+	int i;
 
 	list_for_each_entry_safe(plane, tmpp, plane_list, head)
 		drm_plane_cleanup(plane);
 
+	for (i = 0; i < vop2->data->nr_vps; i++)
+		of_node_put(vop2->vps[i].crtc.port);
+
 	/*
 	 * Destroy CRTC after vop2_plane_destroy() since vop2_disable_plane()
 	 * references the CRTC.
 	 */
-	list_for_each_entry_safe(crtc, tmpc, crtc_list, head) {
-		of_node_put(crtc->port);
+	list_for_each_entry_safe(crtc, tmpc, crtc_list, head)
 		drm_crtc_cleanup(crtc);
-	}
 }
 
 static int vop2_find_rgb_encoder(struct vop2 *vop2)
@@ -3000,7 +3002,7 @@ static int vop2_bind(struct device *dev, struct device *master, void *data)
 
 	ret = vop2_create_crtcs(vop2);
 	if (ret)
-		return ret;
+		goto err_crtcs;
 
 	if (vop2->version >= VOP_VERSION_RK3576) {
 		struct drm_crtc *crtc;
@@ -3010,13 +3012,17 @@ static int vop2_bind(struct device *dev, struct device *master, void *data)
 			int vp_irq;
 			const char *irq_name = devm_kasprintf(dev, GFP_KERNEL, "vp%d", vp->id);
 
-			if (!irq_name)
-				return -ENOMEM;
+			if (!irq_name) {
+				ret = -ENOMEM;
+				goto err_crtcs;
+			}
 
 			vp_irq = platform_get_irq_byname(pdev, irq_name);
-			if (vp_irq < 0)
-				return dev_err_probe(drm->dev, vp_irq,
-						     "cannot find irq for vop2 vp%d\n", vp->id);
+			if (vp_irq < 0) {
+				ret = dev_err_probe(drm->dev, vp_irq,
+						    "cannot find irq for vop2 vp%d\n", vp->id);
+				goto err_crtcs;
+			}
 
 			ret = devm_request_irq(dev, vp_irq, rk3576_vp_isr, IRQF_SHARED, irq_name,
 					       vp);

-- 
2.55.0





More information about the Linux-rockchip mailing list