Skip to contentSkip to conversation

drm/fsl-dcu: fix clock reference leak in fsl_tcon_init error path

PATCH New Miaoqian Lin 1 participant 1 message Dec 19, 2025

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

PATCH 1/1 drm/fsl-dcu: fix clock reference leak in fsl_tcon_init error path

In fsl_tcon_init(), when of_clk_get_by_name() succeeds but clk_prepare_enable() fails, the function jumps to err_node_put label without releasing the clock reference obtained.
This causes a clock reference leak.

Fix by calling clk_put() that properly releases the clock reference.

Found via static analysis and code review.

Fixes fb127b7943c9 ("drm/fsl-dcu: add TCON driver")
---
 drivers/gpu/drm/fsl-dcu/fsl_tcon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/fsl-dcu/fsl_tcon.c +3 -1
index 49bbd00c77ae..b7ba90814b0e 100644
@@ -86,7 +86,7 @@ struct fsl_tcon *fsl_tcon_init(struct device *dev)
 	ret = clk_prepare_enable(tcon->ipg_clk);
 	if (ret) {
 		dev_err(dev, "Couldn't enable the TCON clock\n");
-		goto err_node_put;
+		goto err_clk_put;
 	}
 
 	of_node_put(np);
@@ -94,6 +94,8 @@ struct fsl_tcon *fsl_tcon_init(struct device *dev)
 
 	return tcon;
 
+err_clk_put:
+	clk_put(tcon->ipg_clk);
 err_node_put:
 	of_node_put(np);
 	return NULL;
Signature · 1 line
2.25.1