Skip to content

Commit 53cf1dc

Browse files
sverdlinarndb
authored andcommitted
clk: ep93xx: Fix off by one in ep93xx_div_recalc_rate()
The psc->div[] array has psc->num_div elements. These values come from when we call clk_hw_register_div(). It's adc_divisors and ARRAY_SIZE(adc_divisors)) and so on. So this condition needs to be >= instead of > to prevent an out of bounds read. Fixes: 9645ccc ("ep93xx: clock: convert in-place to COMMON_CLK") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Alexander Sverdlin <[email protected]> Reviewed-by: Nikita Shubin <[email protected]> Signed-off-by: Alexander Sverdlin <[email protected]> Link: https://lore.kernel.org/r/[email protected] [arnd: the original patch was for arch/arm/mach-ep93xx/clock.c, but the same bug ended up in arch/arm/mach-ep93xx/clock.c. Signed-off-by: Arnd Bergmann <[email protected]>
1 parent e2a7910 commit 53cf1dc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/clk/clk-ep93xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ static unsigned long ep93xx_div_recalc_rate(struct clk_hw *hw,
383383

384384
regmap_read(priv->map, clk->reg, &val);
385385
index = (val & clk->mask) >> clk->shift;
386-
if (index > clk->num_div)
386+
if (index >= clk->num_div)
387387
return 0;
388388

389389
return DIV_ROUND_CLOSEST(parent_rate, clk->div[index]);

0 commit comments

Comments
 (0)