From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Anastasia Belova <abelova@astralinux.ru>
Cc: "Michael Turquette" <mturquette@baylibre.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Andreas Färber" <afaerber@suse.de>,
"open list:COMMON CLK FRAMEWORK" <linux-clk@vger.kernel.org>,
"moderated list:ARM/ACTIONS SEMI ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>,
"moderated list:ARM/ACTIONS SEMI ARCHITECTURE"
<linux-actions@lists.infradead.org>,
"open list" <linux-kernel@vger.kernel.org>,
lvc-project@linuxtesting.org, stable@vger.kernel.org
Subject: Re: [PATCH] clk: actions: prevent overflow in owl_pll_recalc_rate
Date: Tue, 10 Sep 2024 22:22:42 +0530 [thread overview]
Message-ID: <20240910165242.v6jcirmtbahxqggx@thinkpad> (raw)
In-Reply-To: <20240910130640.20631-1-abelova@astralinux.ru>
On Tue, Sep 10, 2024 at 04:06:40PM +0300, Anastasia Belova wrote:
> 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@vger.kernel.org>
> Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Currently, val is limited to 8 bits max on the supported SoCs. So there won't be
any overflow. But for the sake of correctness, I'm OK with this patch.
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> 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;
> }
>
> static int owl_pll_is_enabled(struct clk_hw *hw)
> --
> 2.30.2
>
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2024-09-10 16:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 13:06 [PATCH] clk: actions: prevent overflow in owl_pll_recalc_rate Anastasia Belova
2024-09-10 16:52 ` Manivannan Sadhasivam [this message]
2024-10-10 22:21 ` Stephen Boyd
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=20240910165242.v6jcirmtbahxqggx@thinkpad \
--to=manivannan.sadhasivam@linaro.org \
--cc=abelova@astralinux.ru \
--cc=afaerber@suse.de \
--cc=linux-actions@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
/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