From: Jiawen Liu <liu1298662399@gmail.com>
To: Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Michal Simek <michal.simek@amd.com>
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: zynq: Check CPU_2X gate registration before enabling it
Date: Sun, 29 Nov 2026 19:25:33 +0000 [thread overview]
Message-ID: <179598033627.2.16472253499057832801.pattern-ext-064.6@gmail.com> (raw)
During early Zynq boot, of_clk_init() invokes zynq_clk_setup() for the
enabled xlnx,ps7-clkc node. If CPU_2X gate registration fails, for
example on allocation failure, clk_register_gate() returns an error
pointer. clk_prepare_enable() passes it to clk_prepare(), which
dereferences it before the driver's registration check can report the
failure.
Check the CPU_2X registration result before enabling the gate. Keep
the early enable for a valid gate and let the existing registration
check report a failed gate before the clock provider is published.
Static control-flow review, an
ARM multi_v7_defconfig build of drivers/clk/zynq/, git diff --check,
and checkpatch.pl passed. Runtime and hardware reproduction were not
performed.
Fixes: 3dccfecdb867 ("clk: zynq: Force CPU_2X clock to be ungated")
Signed-off-by: Jiawen Liu <liu1298662399@gmail.com>
---
drivers/clk/zynq/clkc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index 777187744f4e5..2464abb2dc831 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -305,7 +305,8 @@ static void __init zynq_clk_setup(struct device_node *np)
clks[cpu_2x] = clk_register_gate(NULL, clk_output_name[cpu_2x],
"cpu_2x_div", CLK_IGNORE_UNUSED, SLCR_ARM_CLK_CTRL,
26, 0, &armclk_lock);
- clk_prepare_enable(clks[cpu_2x]);
+ if (!IS_ERR(clks[cpu_2x]))
+ clk_prepare_enable(clks[cpu_2x]);
clk_register_fixed_factor(NULL, "cpu_1x_div", "cpu_div", 0, 1,
4 + 2 * tmp);
--
2.34.1
reply other threads:[~2026-11-29 20:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=179598033627.2.16472253499057832801.pattern-ext-064.6@gmail.com \
--to=liu1298662399@gmail.com \
--cc=bmasney+clk@redhat.com \
--cc=jbrunet+clk@baylibre.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=sboyd@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