[lvc-project] [PATCH] clk: actions: prevent overflow in owl_pll_recalc_rate

Stephen Boyd sboyd at kernel.org
Fri Oct 11 01:21:45 MSK 2024


Quoting Anastasia Belova (2024-09-10 06:06:40)
> In case of OWL S900 SoC clock driver there are cases
> where bfreq = 24000000, shift = 0. If value read from
> CMU_COREPLL or CMU_DDRPLL to val is big enough, an
> overflow may occur.
> 
> Add explicit casting to prevent it.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 2792c37e94c8 ("clk: actions: Add pll clock support")
> Cc: <stable at vger.kernel.org> 

Seems like we don't need these tags because it can't overflow.

> Signed-off-by: Anastasia Belova <abelova at astralinux.ru>
> ---
>  drivers/clk/actions/owl-pll.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/actions/owl-pll.c b/drivers/clk/actions/owl-pll.c
> index 155f313986b4..fa17567665ec 100644
> --- a/drivers/clk/actions/owl-pll.c
> +++ b/drivers/clk/actions/owl-pll.c
> @@ -104,7 +104,7 @@ static unsigned long owl_pll_recalc_rate(struct clk_hw *hw,
>         val = val >> pll_hw->shift;
>         val &= mul_mask(pll_hw);
>  
> -       return pll_hw->bfreq * val;
> +       return (unsigned long)pll_hw->bfreq * val;

I'm lost. Did you intend to cast this to a u64?



More information about the lvc-project mailing list