mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clk: imx: pll14xx: Fix potential integer overflow
@ 2026-11-05  9:46 Stefan Ghetu
  0 siblings, 0 replies; only message in thread
From: Stefan Ghetu @ 2026-11-05  9:46 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 results will also be 64-bit)
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>
---
 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..08f9d3fbc75f 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 + (u64)kdiv);
 	pdiv *= 65536;
 
 	do_div(fout, pdiv << sdiv);
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-05  9:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05  9:46 [PATCH] clk: imx: pll14xx: Fix potential integer overflow Stefan Ghetu

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®