>From 55466ce37d710051279174f70d4f2f89af161636 Mon Sep 17 00:00:00 2001
From: Wentao Liang <[email protected]>
Date: Fri, 6 Nov 2026 08:58:25 +0000
Subject: [PATCH v2] drm/tidss: Fix serial clock reference leak in
 tidss_oldi_init()

The reference to the OLDI serial clock taken with of_clk_get_by_name()
is kept in the OLDI bridge structure for the whole driver lifetime, but
it is never released.

On driver unbind, tidss_oldi_deinit() removes the bridges without
dropping that reference. The situation is worse when the OLDI
initialisation fails for a second transmitter: tidss_oldi_init() returns
an error and tidss_oldi_deinit() is not called at all, so the reference
taken for the first transmitter leaks too.

Use devm_get_clk_from_child() instead, which is of_clk_get_by_name()
with a device managed reference. The clock is then released when the
driver is unbound, or when probe fails.

The candidate issue was found with static analysis tools.
DeepSeek-V4.1-Flash and GPT-6.1 Sol were used to help audit the error
paths and to prepare this change; the result was reviewed manually
before submission.

Fixes: 7246e0929945 ("drm/tidss: Add OLDI bridge support")
Cc: [email protected]
Reported-by: Tomi Valkeinen <[email protected]>
Closes: 
https://lore.kernel.org/r/[email protected]
Signed-off-by: Wentao Liang <[email protected]>
---
Changes in v2:
- Use devm_get_clk_from_child() instead of adding a clk_put() to
  tidss_oldi_deinit(), so that the clock reference is also released when
  tidss_oldi_init() fails for a later OLDI transmitter.
- Apologies for the very late reply.

 drivers/gpu/drm/tidss/tidss_oldi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tidss/tidss_oldi.c 
b/drivers/gpu/drm/tidss/tidss_oldi.c
index 5eb749f495d5..485e9f862fb6 100644
--- a/drivers/gpu/drm/tidss/tidss_oldi.c
+++ b/drivers/gpu/drm/tidss/tidss_oldi.c
@@ -586,7 +586,8 @@ int tidss_oldi_init(struct tidss_device *tidss)
                                goto err_put_node;
                        }
 
-                       oldi->serial = of_clk_get_by_name(child, "serial");
+                       oldi->serial = devm_get_clk_from_child(tidss->dev, 
child,
+                                                              "serial");
                        if (IS_ERR(oldi->serial)) {
                                ret = dev_err_probe(oldi->dev, 
PTR_ERR(oldi->serial),
                                                    "OLDI%u: Failed to get 
serial clock.\n",

Reply via email to