From: WenTao Liang <vulab@iscas.ac.cn>
To: paul@crapouillou.net, mturquette@baylibre.com, sboyd@kernel.org
Cc: bmasney@redhat.com, linux-mips@vger.kernel.org,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
WenTao Liang <vulab@iscas.ac.cn>,
Greg KH <gregkh@linuxfoundation.org>,
stable@vger.kernel.org
Subject: [PATCH v2] clk/ingenic: fix clock leak on clk_register_clkdev failure
Date: Sun, 28 Jun 2026 20:28:11 +0800 [thread overview]
Message-ID: <20260628122811.44799-1-vulab@iscas.ac.cn> (raw)
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.
Suggested-by: Greg KH <gregkh@linuxfoundation.org>
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
---
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)
next reply other threads:[~2026-06-28 12:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 12:28 WenTao Liang [this message]
2026-07-06 19:59 ` [PATCH v2] clk/ingenic: fix clock leak on clk_register_clkdev failure Brian Masney
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=20260628122811.44799-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox