From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Abel Vesa <abelvesa@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
linux-clk@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] clk: imx: pll14xx: Fix potential integer overflow on multiplication
Date: Mon, 7 Oct 2024 11:00:46 +0100 [thread overview]
Message-ID: <6181060a-ae36-4d0f-bfe0-c1e5c8a8ab3c@gmail.com> (raw)
In-Reply-To: <3e0def9f-ebb6-4171-9395-1da118b0ea29@stanley.mountain>
On 07/10/2024 10:54, Dan Carpenter wrote:
> On Mon, Oct 07, 2024 at 09:48:40AM +0100, Colin Ian King wrote:
>> The calculation of fout is using int multiplication and assigning
>> the result to a u64, this can potentially overflow if the int variable
>> mdiv is too large. Fix this by making the 65536 a u64 value to ensure a
>> u64 multiplication is being performed to avoid the overflow.
>>
>> Fixes: 53990cf9d5b4 ("clk: imx: pll14xx: consolidate rate calculation")
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>
> mdiv is always clamped in then 0-1023 range by one of these:
>
> mdiv = FIELD_GET(MDIV_MASK, pll_div_ctl0);
> mdiv = clamp(mdiv, 64, 1023);
>
> so it can't overflow and the Fixes tag is unnecessary.
Good point.
>
> I think the reason why "fout" is declared as a u64 is because we were worried
> that on 32 bit systems the "fout *=" operation could overflow. That looks
> reasonable to me.
Yes, that makes perfect sense. NAK my patch. Apologies for the noise.
Colin
>
> regards,
> dan carpenter
>
prev parent reply other threads:[~2024-10-07 10:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 8:48 [PATCH][next] clk: imx: pll14xx: Fix potential integer overflow on multiplication Colin Ian King
2024-10-07 9:54 ` Dan Carpenter
2024-10-07 10:00 ` Colin King (gmail) [this message]
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=6181060a-ae36-4d0f-bfe0-c1e5c8a8ab3c@gmail.com \
--to=colin.i.king@gmail.com \
--cc=abelvesa@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel-janitors@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@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