All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Masney <bmasney@redhat.com>
To: WenTao Liang <vulab@iscas.ac.cn>
Cc: paul@crapouillou.net, mturquette@baylibre.com, sboyd@kernel.org,
	linux-mips@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Greg KH <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] clk/ingenic: fix clock leak on clk_register_clkdev failure
Date: Mon, 6 Jul 2026 15:59:06 -0400	[thread overview]
Message-ID: <akwJCq9uUY3rzFxe@redhat.com> (raw)
In-Reply-To: <20260628122811.44799-1-vulab@iscas.ac.cn>

On Sun, Jun 28, 2026 at 08:28:11PM +0800, WenTao Liang wrote:
> clk_register() succeeds but clk_register_clkdev() fails, and the error
> path jumps to out without calling clk_unregister or clk_put to release
> the registered clock. This leaks the clock object within the common clock
> framework


> , contrasting with the CGU_CLK_EXT type path which correctly
> calls clk_put on error.

I would drop this part. Just focus on what you are fixing.

> 
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>

I don't see where on the v1 Greg suggested this, unless I am missing
something?

> Fixes: b066303fb3e7 ("clk: ingenic: add driver for Ingenic SoC CGU clocks")
> Cc: stable@vger.kernel.org
> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
> ---
> Changes in v2:
> - Fix patch format based on reviewer feedback

Link to v1: https://lore.kernel.org/linux-clk/20260626115644.33779-1-vulab@iscas.ac.cn/

With those fixes:

Reviewed-by: Brian Masney <bmasney@redhat.com>


> ---
>  drivers/clk/ingenic/cgu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c
> index 41e4c69131bd..b59b24d0e3cf 100644
> --- a/drivers/clk/ingenic/cgu.c
> +++ b/drivers/clk/ingenic/cgu.c
> @@ -774,8 +774,10 @@ static int ingenic_register_clock(struct ingenic_cgu *cgu, unsigned idx)
>  	}
>  
>  	err = clk_register_clkdev(clk, clk_info->name, NULL);
> -	if (err)
> +	if (err) {
> +		clk_unregister(clk);
>  		goto out;
> +	}
>  
>  	cgu->clocks.clks[idx] = clk;
>  out:
> -- 
> 2.39.5 (Apple Git-154)
> 


  reply	other threads:[~2026-07-06 19:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-28 12:28 [PATCH v2] clk/ingenic: fix clock leak on clk_register_clkdev failure WenTao Liang
2026-07-06 19:59 ` Brian Masney [this message]
2026-07-07  4:25   ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=akwJCq9uUY3rzFxe@redhat.com \
    --to=bmasney@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=paul@crapouillou.net \
    --cc=sboyd@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.