[PATCH 04/10] clk: composite: Initialise sub-hw pointers in determine_rate()

From: Lee Jones

Date: Mon Nov 23 2026 - 11:49:21 EST


__clk_hw_register_composite() leaves mux_hw->core and rate_hw->core
unset at registration time, relying on the composite callbacks to bind
them via __clk_hw_set_clk(). While the fallback branches of
clk_composite_determine_rate() and clk_composite_set_rate_and_parent()
call __clk_hw_set_clk(), the primary rate + mux branch omits it.

When a composite clock with both rate and mux operations has only a
single parent, __clk_init_parent() skips .get_parent(), leaving
mux_hw->core NULL. Subsequent calls to clk_hw_get_parent(mux_hw) or
clk_hw_get_num_parents(mux_hw) in clk_composite_determine_rate() then
dereference NULL.

Call __clk_hw_set_clk() for both rate_hw and mux_hw in the primary
branch of clk_composite_determine_rate().

Fixes: 2f508a955a67 ("clk: Convert basic types to clk_hw based provider APIs")
Closes: https://sashiko.dev/#/bug/linux-55b1d094-a5a2-44a2-b323-dddc52661f32
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/clk/clk-composite.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 11842bce5918..c7c1ff590e14 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -69,6 +69,8 @@ static int clk_composite_determine_rate(struct clk_hw *hw,

if (rate_hw && rate_ops && rate_ops->determine_rate &&
mux_hw && mux_ops && mux_ops->set_parent) {
+ __clk_hw_set_clk(rate_hw, hw);
+ __clk_hw_set_clk(mux_hw, hw);
req->best_parent_hw = NULL;

if (clk_hw_get_flags(hw) & CLK_SET_RATE_NO_REPARENT) {
--
2.56.1.750.gf70dc682cf-goog