Skip to content

Commit c7f0628

Browse files
sverdlinarndb
authored andcommitted
ep93xx: clock: 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 <dan.carpenter@linaro.org> Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Reviewed-by: Nikita Shubin <nikita.shubin@maquefel.me> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Link: https://lore.kernel.org/r/1caf01ad4c0a8069535813c26c7f0b8ea011155e.camel@linaro.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 47ac09b commit c7f0628

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/arm/mach-ep93xx/clock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static unsigned long ep93xx_div_recalc_rate(struct clk_hw *hw,
359359
u32 val = __raw_readl(psc->reg);
360360
u8 index = (val & psc->mask) >> psc->shift;
361361

362-
if (index > psc->num_div)
362+
if (index >= psc->num_div)
363363
return 0;
364364

365365
return DIV_ROUND_UP_ULL(parent_rate, psc->div[index]);

0 commit comments

Comments
 (0)