diff options
| author | Christian Marangi <ansuelsmth@gmail.com> | 2025-03-15 10:24:14 +0100 |
|---|---|---|
| committer | Tom Rini <trini@konsulko.com> | 2025-04-30 07:50:18 -0600 |
| commit | aa96cda0a58f4d181b81a897b0b9fea3d9729478 (patch) | |
| tree | 3edbea8e1803c2810941bf675fadbb131a5ca3ca /drivers/clk/clk-uclass.c | |
| parent | a6da395b5d68ad0e644e0a70665274dc60ec2056 (diff) | |
clk: fix crash on clk_set_rate clean rate cache
It's currently possible to make the bootloader crash on calling
clk_set_rate caused by the loop in clk_clean_rate_cache.
The loop assume that every child of the clock node are also clock
device but this is not always the case. For example it's common for a
clock to bind to a reset device or also expose a syscon if the clock
register map is also used to apply special configuration.
In such case, on accessing a device as a clock, the bootloader crash. To
correctly handle this, check if the child device is actually a clock and
ignore otherwise.
Fixes: 6b7fd3128f71 ("clk: fix set_rate to clean up cached rates for the hierarchy")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Diffstat (limited to 'drivers/clk/clk-uclass.c')
| -rw-r--r-- | drivers/clk/clk-uclass.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 4b3d812f9c6..bc4d76277cd 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -572,6 +572,9 @@ static void clk_clean_rate_cache(struct clk *clk) clk->rate = 0; list_for_each_entry(child_dev, &clk->dev->child_head, sibling_node) { + if (device_get_uclass_id(child_dev) != UCLASS_CLK) + continue; + clkp = dev_get_clk_ptr(child_dev); clk_clean_rate_cache(clkp); } |
