* [PATCH v2] clk: imx: pll14xx: Fix potential integer overflow
@ 2026-11-09 11:31 Stefan Ghetu
2026-11-09 11:51 ` Daniel Baluta
2026-11-09 12:39 ` Peng Fan
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Ghetu @ 2026-11-09 11:31 UTC (permalink / raw)
To: abelvesa, peng.fan, sboyd
Cc: bmasney+clk, jbrunet+clk, Frank.Li, s.hauer, kernel, festevam,
linux-clk, imx, linux-arm-kernel, linux-kernel, Florin Pavelescu,
Stefan Ghetu
From: Florin Pavelescu <florin.pavelescu@nxp.com>
Cast to u64, so that multiplications and additions will be done
in 64-bit arithmetic and the possibility of integer overflow is eliminated.
Fixes: 53990cf9d5b48 ("clk: imx: pll14xx: consolidate rate calculation")
Signed-off-by: Florin Pavelescu <florin.pavelescu@nxp.com>
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
---
Changes in v2:
- Drop the redundant (u64) cast on kdiv, as suggested by Frank Li.
Adding a 32-bit value to a u64 already promotes it to u64.
drivers/clk/imx/clk-pll14xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c
index c6438144e507..ee9a9e4c392a 100644
--- a/drivers/clk/imx/clk-pll14xx.c
+++ b/drivers/clk/imx/clk-pll14xx.c
@@ -124,7 +124,7 @@ static long pll14xx_calc_rate(struct clk_pll14xx *pll, int mdiv, int pdiv,
u64 fout = prate;
/* fout = (m * 65536 + k) * Fin / (p * 65536) / (1 << sdiv) */
- fout *= (mdiv * 65536 + kdiv);
+ fout *= ((u64)mdiv * 65536 + kdiv);
pdiv *= 65536;
do_div(fout, pdiv << sdiv);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] clk: imx: pll14xx: Fix potential integer overflow
2026-11-09 11:31 [PATCH v2] clk: imx: pll14xx: Fix potential integer overflow Stefan Ghetu
@ 2026-11-09 11:51 ` Daniel Baluta
2026-11-09 12:39 ` Peng Fan
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Baluta @ 2026-11-09 11:51 UTC (permalink / raw)
To: Stefan Ghetu, abelvesa, peng.fan, sboyd
Cc: bmasney+clk, jbrunet+clk, Frank.Li, s.hauer, kernel, festevam,
linux-clk, imx, linux-arm-kernel, linux-kernel, Florin Pavelescu
On 11/9/26 13:31, Stefan Ghetu wrote:
> [You don't often get email from stefan.ghetu@nxp.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Florin Pavelescu <florin.pavelescu@nxp.com>
>
> Cast to u64, so that multiplications and additions will be done
> in 64-bit arithmetic and the possibility of integer overflow is eliminated.
>
> Fixes: 53990cf9d5b48 ("clk: imx: pll14xx: consolidate rate calculation")
> Signed-off-by: Florin Pavelescu <florin.pavelescu@nxp.com>
> Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] clk: imx: pll14xx: Fix potential integer overflow
2026-11-09 11:31 [PATCH v2] clk: imx: pll14xx: Fix potential integer overflow Stefan Ghetu
2026-11-09 11:51 ` Daniel Baluta
@ 2026-11-09 12:39 ` Peng Fan
1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2026-11-09 12:39 UTC (permalink / raw)
To: Stefan Ghetu
Cc: abelvesa, peng.fan, sboyd, bmasney+clk, jbrunet+clk, Frank.Li,
s.hauer, kernel, festevam, linux-clk, imx, linux-arm-kernel,
linux-kernel, Florin Pavelescu
On Mon, Nov 09, 2026 at 01:31:38PM +0200, Stefan Ghetu wrote:
>From: Florin Pavelescu <florin.pavelescu@nxp.com>
>
>Cast to u64, so that multiplications and additions will be done
>in 64-bit arithmetic and the possibility of integer overflow is eliminated.
>
>Fixes: 53990cf9d5b48 ("clk: imx: pll14xx: consolidate rate calculation")
>Signed-off-by: Florin Pavelescu <florin.pavelescu@nxp.com>
>Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
It will not overflow. See this:
https://lore.kernel.org/all/6181060a-ae36-4d0f-bfe0-c1e5c8a8ab3c@gmail.com/
If we do want to silence some warnings from tools, drop the Fixes tag,
and update to commit message accordingly.
Regards
Peng
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-09 12:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 11:31 [PATCH v2] clk: imx: pll14xx: Fix potential integer overflow Stefan Ghetu
2026-11-09 11:51 ` Daniel Baluta
2026-11-09 12:39 ` Peng Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®