Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nikita Shubin <nikita.shubin@maquefel.me>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	Alexander Sverdlin <alexander.sverdlin@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>
Cc: Hartley Sweeten <hsweeten@visionengravers.com>,
	Russell King <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ep93xx: clock: Fix off by one in ep93xx_div_recalc_rate()
Date: Wed, 11 Sep 2024 11:14:23 +0300	[thread overview]
Message-ID: <246de2986dce9d867894bb006a1b2b3601e94a4e.camel@maquefel.me> (raw)
In-Reply-To: <a05454f8-e409-4f60-93f7-6aa2ea0a2a23@stanley.mountain>

Hi Dan!

Reviewed-by: Nikita Shubin <nikita.shubin@maquefel.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@linaro.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]);



  parent reply	other threads:[~2024-09-11  8:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11  7:39 [PATCH] ep93xx: clock: Fix off by one in ep93xx_div_recalc_rate() Dan Carpenter
2024-09-11  7:52 ` Alexander Sverdlin
2024-09-11  8:14 ` Nikita Shubin [this message]
2024-09-11 14:54   ` Arnd Bergmann
2024-09-11 14:59     ` Alexander Sverdlin
2024-09-11 16:28       ` Nikita Shubin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=246de2986dce9d867894bb006a1b2b3601e94a4e.camel@maquefel.me \
    --to=nikita.shubin@maquefel.me \
    --cc=alexander.sverdlin@gmail.com \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@linaro.org \
    --cc=hsweeten@visionengravers.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox