mirror of
https://github.com/torvalds/linux.git
synced 2024-09-20 15:03:04 +00:00
clk: sunxi-ng: common: Don't call hw_to_ccu_common on hw without common
In order to set the rate range of a hw sunxi_ccu_probe calls
hw_to_ccu_common() assuming all entries in desc->ccu_clks are contained
in a ccu_common struct. This assumption is incorrect and, in
consequence, causes invalid pointer de-references.
Remove the faulty call. Instead, add one more loop that iterates over
the ccu_clks and sets the rate range, if required.
Fixes: b914ec33b3
("clk: sunxi-ng: common: Support minimum and maximum rate")
Reported-by: Robert J. Pafford <pafford.9@buckeyemail.osu.edu>
Closes: https://lore.kernel.org/lkml/DM6PR01MB58047C810DDD5D0AE397CADFF7C22@DM6PR01MB5804.prod.exchangelabs.com/
Cc: stable@vger.kernel.org
Signed-off-by: Frank Oltmanns <frank@oltmanns.dev>
Tested-by: Robert J. Pafford <pafford.9@buckeyemail.osu.edu>
Link: https://lore.kernel.org/r/20240623-sunxi-ng_fix_common_probe-v1-1-7c97e32824a1@oltmanns.dev
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
This commit is contained in:
parent
1613e604df
commit
ea977d7425
|
@ -132,7 +132,6 @@ static int sunxi_ccu_probe(struct sunxi_ccu *ccu, struct device *dev,
|
|||
|
||||
for (i = 0; i < desc->hw_clks->num ; i++) {
|
||||
struct clk_hw *hw = desc->hw_clks->hws[i];
|
||||
struct ccu_common *common = hw_to_ccu_common(hw);
|
||||
const char *name;
|
||||
|
||||
if (!hw)
|
||||
|
@ -147,14 +146,21 @@ static int sunxi_ccu_probe(struct sunxi_ccu *ccu, struct device *dev,
|
|||
pr_err("Couldn't register clock %d - %s\n", i, name);
|
||||
goto err_clk_unreg;
|
||||
}
|
||||
}
|
||||
|
||||
if (common->max_rate)
|
||||
clk_hw_set_rate_range(hw, common->min_rate,
|
||||
common->max_rate);
|
||||
for (i = 0; i < desc->num_ccu_clks; i++) {
|
||||
struct ccu_common *cclk = desc->ccu_clks[i];
|
||||
|
||||
if (!cclk)
|
||||
continue;
|
||||
|
||||
if (cclk->max_rate)
|
||||
clk_hw_set_rate_range(&cclk->hw, cclk->min_rate,
|
||||
cclk->max_rate);
|
||||
else
|
||||
WARN(common->min_rate,
|
||||
WARN(cclk->min_rate,
|
||||
"No max_rate, ignoring min_rate of clock %d - %s\n",
|
||||
i, name);
|
||||
i, clk_hw_get_name(&cclk->hw));
|
||||
}
|
||||
|
||||
ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
|
||||
|
|
Loading…
Reference in New Issue
Block a user