[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <246de2986dce9d867894bb006a1b2b3601e94a4e.camel@maquefel.me>
Date: Wed, 11 Sep 2024 11:14:23 +0300
From: Nikita Shubin <nikita.shubin@...uefel.me>
To: Dan Carpenter <dan.carpenter@...aro.org>, Alexander Sverdlin
<alexander.sverdlin@...il.com>, Arnd Bergmann <arnd@...db.de>
Cc: Hartley Sweeten <hsweeten@...ionengravers.com>, Russell King
<linux@...linux.org.uk>, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] ep93xx: clock: Fix off by one in
ep93xx_div_recalc_rate()
Hi Dan!
Reviewed-by: Nikita Shubin <nikita.shubin@...uefel.me>
Alexander, Arnd
unfortunately, the ep93xx DT conversion series is also affected by this
bug.
On Wed, 2024-09-11 at 10:39 +0300, Dan Carpenter wrote:
> 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: 9645ccc7bd7a ("ep93xx: clock: convert in-place to COMMON_CLK")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---
> arch/arm/mach-ep93xx/clock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-
> ep93xx/clock.c
> index 85a496ddc619..e9f72a529b50 100644
> --- a/arch/arm/mach-ep93xx/clock.c
> +++ b/arch/arm/mach-ep93xx/clock.c
> @@ -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]);
Powered by blists - more mailing lists