[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240504-imx-clk-v1-7-f7915489d58d@nxp.com>
Date: Sat, 04 May 2024 08:49:00 +0800
From: "Peng Fan (OSS)" <peng.fan@....nxp.com>
To: Abel Vesa <abelvesa@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Jacky Bai <ping.bai@....com>,
Ye Li <ye.li@....com>, Dong Aisheng <aisheng.dong@....com>
Cc: linux-clk@...r.kernel.org, imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Abel Vesa <abel.vesa@...aro.org>, Peng Fan <peng.fan@....com>,
Florin Pavelescu <florin.pavelescu@....com>,
Viorel Suman <viorel.suman@....com>
Subject: [PATCH 07/18] clk: imx: pll14xx: potential integer overflow
eliminated by casting to u64
From: Florin Pavelescu <florin.pavelescu@....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.
Fix Unintentional integer overflow reported by Coverity
Reviewed-by: Viorel Suman <viorel.suman@....com>
Signed-off-by: Florin Pavelescu <florin.pavelescu@....com>
Signed-off-by: Peng Fan <peng.fan@....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 6b2c849f8b71..78eedb1f4a79 100644
--- a/drivers/clk/imx/clk-pll14xx.c
+++ b/drivers/clk/imx/clk-pll14xx.c
@@ -118,7 +118,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.37.1
Powered by blists - more mailing lists