[PATCH v2] drm/tidss: Fix serial clock reference leak in tidss_oldi_init()

From: Wentao Liang

Date: Fri Nov 06 2026 - 03:58:25 EST


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: stable@xxxxxxxxxxxxxxx
Reported-by: Tomi Valkeinen <tomi.valkeinen@xxxxxxxxxxxxxxxx>
Closes: https://lore.kernel.org/r/59a88d56-264f-4540-90e3-b9f609681486@xxxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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",