imx_get_clk_hw_by_name() obtains a consumer clock with of_clk_get_by_name(), extracts the hardware pointer with __clk_get_hw() and returns it without ever calling clk_put(), leaking the consumer reference on both return paths. Extract the hardware pointer first and drop the clock reference with clk_put() before returning. Fixes: 3b315214e091 ("clk: imx: implement new clk_hw based APIs") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang --- drivers/clk/imx/clk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c index f38506830ccf..e113e30514fa 100644 --- a/drivers/clk/imx/clk.c +++ b/drivers/clk/imx/clk.c @@ -119,12 +119,16 @@ struct clk_hw *imx_obtain_fixed_of_clock(struct device_node *np, struct clk_hw *imx_get_clk_hw_by_name(struct device_node *np, const char *name) { struct clk *clk; + struct clk_hw *hw; clk = of_clk_get_by_name(np, name); if (IS_ERR(clk)) return ERR_PTR(-ENOENT); - return __clk_get_hw(clk); + hw = __clk_get_hw(clk); + clk_put(clk); + + return hw; } EXPORT_SYMBOL_GPL(imx_get_clk_hw_by_name); -- 2.34.1