Commit b64b2497 authored by Dan Carpenter's avatar Dan Carpenter Committed by Zhang Kunbo
Browse files

ep93xx: clock: Fix off by one in ep93xx_div_recalc_rate()

stable inclusion
from stable-v6.6.54
commit 66e78ade976dbd9bea09166aa8d66afc0963cde4
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYPJL
CVE: CVE-2024-47686

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=66e78ade976dbd9bea09166aa8d66afc0963cde4



--------------------------------

[ Upstream commit c7f06284a6427475e3df742215535ec3f6cd9662 ]

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: 9645ccc7 ("ep93xx: clock: convert in-place to COMMON_CLK")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Acked-by: default avatarAlexander Sverdlin <alexander.sverdlin@gmail.com>
Reviewed-by: default avatarNikita Shubin <nikita.shubin@maquefel.me>
Signed-off-by: default avatarAlexander Sverdlin <alexander.sverdlin@gmail.com>
Link: https://lore.kernel.org/r/1caf01ad4c0a8069535813c26c7f0b8ea011155e.camel@linaro.org


Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarZhang Kunbo <zhangkunbo@huawei.com>
parent 09350f59
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ static unsigned long ep93xx_div_recalc_rate(struct clk_hw *hw,
	u32 val = __raw_readl(psc->reg);
	u8 index = (val & psc->mask) >> psc->shift;

	if (index > psc->num_div)
	if (index >= psc->num_div)
		return 0;

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