mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/6] clk: qoriq: Fix clock reference leak in input_clock_by_index()
@ 2026-09-15  4:28 Wentao Liang
  2026-09-27 16:02 ` Jerome Brunet
  0 siblings, 1 reply; 3+ messages in thread
From: Wentao Liang @ 2026-09-15  4:28 UTC (permalink / raw)
  To: andy.tang
  Cc: bmasney, linux-clk, linux-kernel, mturquette, oss, robh, sboyd,
	lkml, Wentao Liang, stable

input_clock_by_index() obtains a consumer clock with of_clk_get() 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() 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@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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 2524c5c0eb46..2ed8f93bc861 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -1135,13 +1135,16 @@ static struct clk __init *input_clock_by_name(const char *name,
 
 static struct clk __init *input_clock_by_index(const char *name, int idx)
 {
-	struct clk *clk;
+	struct clk *clk, *ret;
 
 	clk = of_clk_get(clockgen.node, 0);
 	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 create_sysclk(const char *name)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/6] clk: qoriq: Fix clock reference leak in input_clock_by_index()
  2026-09-15  4:28 [PATCH 2/6] clk: qoriq: Fix clock reference leak in input_clock_by_index() Wentao Liang
@ 2026-09-27 16:02 ` Jerome Brunet
  2026-11-05  8:55   ` Wentao Liang
  0 siblings, 1 reply; 3+ messages in thread
From: Jerome Brunet @ 2026-09-27 16:02 UTC (permalink / raw)
  To: Wentao Liang, andy.tang
  Cc: bmasney, linux-clk, linux-kernel, mturquette, oss, robh, sboyd,
	lkml, Wentao Liang, stable

On mar. 15 sept. 2026 at 04:28, Wentao Liang <vulab@iscas.ac.cn> wrote:

> input_clock_by_index() obtains a consumer clock with of_clk_get() 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() 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@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

This is PATCH 2 out 6 but there is not thread, cover letter or other
patches. I can't tell if there is a context I should be aware of.

Please check how you've send this. Consider using b4.

> ---
>  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 2524c5c0eb46..2ed8f93bc861 100644
> --- a/drivers/clk/clk-qoriq.c
> +++ b/drivers/clk/clk-qoriq.c
> @@ -1135,13 +1135,16 @@ static struct clk __init *input_clock_by_name(const char *name,
>  
>  static struct clk __init *input_clock_by_index(const char *name, int idx)
>  {
> -	struct clk *clk;
> +	struct clk *clk, *ret;
>  
>  	clk = of_clk_get(clockgen.node, 0);
>  	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 create_sysclk(const char *name)
> -- 
> 2.34.1
>

-- 
Jerome

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/6] clk: qoriq: Fix clock reference leak in input_clock_by_index()
  2026-09-27 16:02 ` Jerome Brunet
@ 2026-11-05  8:55   ` Wentao Liang
  0 siblings, 0 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-05  8:55 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: andy.tang, bmasney, linux-clk, linux-kernel, lkml, mturquette,
	oss, robh, sboyd, stable, vulab

Hi Jerome,

> This is PATCH 2 out 6 but there is not thread, cover letter or other
> patches. I can't tell if there is a context I should be aware of.

Thank you for the review, and sorry for the delayed reply and the
confusing submission.

The six patches are independent leak fixes across cpufreq, clk, driver
core, and perf. They were grouped only for convenience and do not depend
on each other; there is no additional context needed from the other
patches to review this one. I sent them without a cover letter or proper
threading, leaving this patch on its own despite the 2/6 numbering.
That was my submission mistake.

> Please check how you've send this. Consider using b4.

Thank you for the suggestion. I will check the submission workflow and
look into using b4 for future submissions.

Sorry again for the delay and the submission error. To avoid adding to
your review workload, I will hold off on resending this patch for now.
If you would prefer a resend as a standalone patch without the series
numbering, please let me know.

Best regards,
Wentao Liang


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-05  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  4:28 [PATCH 2/6] clk: qoriq: Fix clock reference leak in input_clock_by_index() Wentao Liang
2026-09-27 16:02 ` Jerome Brunet
2026-11-05  8:55   ` Wentao Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®