[PATCH] drm/logicvc: Fix port node reference leak in logicvc_crtc_init()

From: Jason Xiang

Date: Thu Jun 25 2026 - 09:31:50 EST


of_graph_get_port_by_id() returns the port node with its reference
count incremented; the caller has to drop that reference with
of_node_put() when done. logicvc_crtc_init() stores the node in
crtc->port but never releases it. The core CRTC cleanup
(drm_crtc_cleanup()) does not put crtc->port either, so the reference
is leaked on unbind, and also on any probe error after this point.

Drop the reference with a device-managed action, as done in other
DRM drivers (e.g. arm/malidp, arm/hdlcd). The leak has been present
since the driver was introduced.

Fixes: efeeaefe9be5 ("drm: Add support for the LogiCVC display controller")
Signed-off-by: Jason Xiang <jx@xxxxxxxxxxxxxx>
---
drivers/gpu/drm/logicvc/logicvc_crtc.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/logicvc/logicvc_crtc.c b/drivers/gpu/drm/logicvc/logicvc_crtc.c
index 81e5b80736fa..4de48822ca21 100644
--- a/drivers/gpu/drm/logicvc/logicvc_crtc.c
+++ b/drivers/gpu/drm/logicvc/logicvc_crtc.c
@@ -243,6 +243,11 @@ void logicvc_crtc_vblank_handler(struct logicvc_drm *logicvc)
}
}

+static void logicvc_crtc_of_node_put(void *data)
+{
+ of_node_put(data);
+}
+
int logicvc_crtc_init(struct logicvc_drm *logicvc)
{
struct drm_device *drm_dev = &logicvc->drm_dev;
@@ -274,6 +279,10 @@ int logicvc_crtc_init(struct logicvc_drm *logicvc)

crtc->drm_crtc.port = of_graph_get_port_by_id(of_node, 1);

+ ret = devm_add_action_or_reset(dev, logicvc_crtc_of_node_put, crtc->drm_crtc.port);
+ if (ret)
+ return ret;
+
logicvc->crtc = crtc;

return 0;

base-commit: f0e6f20cb52b14c2c441f04e21cef0c95d498cac
--
2.53.0