linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: imx: fix integer overflow in AV PLL round rate
@ 2016-10-06 11:12 Emil Lundmark
  2016-10-06 11:12 ` [PATCH 2/2] ARM: imx: improve precision of AV PLL to 1 Hz Emil Lundmark
  2016-10-07 14:12 ` [PATCH 1/2] ARM: imx: fix integer overflow in AV PLL round rate Emil Lundmark
  0 siblings, 2 replies; 8+ messages in thread
From: Emil Lundmark @ 2016-10-06 11:12 UTC (permalink / raw)
  To: linux-arm-kernel

Since parent_rate * mfn may overflow 32 bits, the result should be stored
using 64 bits.

This issue was previously addressed in ba7f4f557eb6, but this particular
case was not fixed.

Signed-off-by: Emil Lundmark <emil@limesaudio.com>
---
 drivers/clk/imx/clk-pllv3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
index 19f9b62..bc7f163 100644
--- a/drivers/clk/imx/clk-pllv3.c
+++ b/drivers/clk/imx/clk-pllv3.c
@@ -247,7 +247,11 @@ static long clk_pllv3_av_round_rate(struct clk_hw *hw, unsigned long rate,
 	do_div(temp64, parent_rate);
 	mfn = temp64;
 
-	return parent_rate * div + parent_rate * mfn / mfd;
+	temp64 = (u64)parent_rate;
+	temp64 *= mfn;
+	do_div(temp64, mfd);
+
+	return parent_rate * div + (u32)temp64;
 }
 
 static int clk_pllv3_av_set_rate(struct clk_hw *hw, unsigned long rate,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-10-07 16:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-06 11:12 [PATCH 1/2] ARM: imx: fix integer overflow in AV PLL round rate Emil Lundmark
2016-10-06 11:12 ` [PATCH 2/2] ARM: imx: improve precision of AV PLL to 1 Hz Emil Lundmark
2016-10-07  7:48   ` Lothar Waßmann
2016-10-07 13:55     ` Emil Lundmark
2016-10-07 14:12 ` [PATCH 1/2] ARM: imx: fix integer overflow in AV PLL round rate Emil Lundmark
2016-10-07 15:34   ` Fabio Estevam
2016-10-07 16:02     ` Emil Lundmark
2016-10-07 16:51       ` Fabio Estevam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).