[PATCH 3/6] clk: qoriq: Fix clock reference leak in input_clock_by_name()

From: Wentao Liang

Date: Tue Sep 15 2026 - 00:32:34 EST


input_clock_by_name() obtains a consumer clock with of_clk_get_by_name()
and hands it to input_clock(), which only uses __clk_get_name() to read
the clock name and then registers a new fixed factor clock. The
consumer clock itself is discarded without clk_put(), so the reference
returned by of_clk_get_by_name() is never released.

Release the reference with clk_put() once input_clock() is done with
the clock, mirroring the pattern used by of_clk_get_parent_name().

Fixes: 80b4ae7acea4 ("clk: qoriq: Separate root input clock for core PLLs on ls1012a")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/clk/clk-qoriq.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index 2ed8f93bc861..d0091b388cef 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -1124,13 +1124,16 @@ static struct clk __init *input_clock(const char *name, struct clk *clk)
static struct clk __init *input_clock_by_name(const char *name,
const char *dtname)
{
- struct clk *clk;
+ struct clk *clk, *ret;

clk = of_clk_get_by_name(clockgen.node, dtname);
if (IS_ERR(clk))
return clk;

- return input_clock(name, clk);
+ ret = input_clock(name, clk);
+ clk_put(clk);
+
+ return ret;
}

static struct clk __init *input_clock_by_index(const char *name, int idx)
--
2.34.1