projects
/
GitHub
/
LineageOS
/
android_kernel_motorola_exynos9610.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b106229
)
clk: atlas7: fix integer overflow in dto rate calculation
author
Yibo Cai
<yibo.cai@csr.com>
Tue, 4 Aug 2015 14:45:28 +0000
(14:45 +0000)
committer
Michael Turquette
<mturquette@baylibre.com>
Mon, 24 Aug 2015 23:49:06 +0000
(16:49 -0700)
I cannot believe that I spend quite a lot time in finding this bug.
It seems a pitfall people tend to fall in.
In "int64 = int32 * int32", conversion from 32-bits to 64-bits comes
after the multiplication. So this statement may not work as expected.
Signed-off-by: Yibo Cai <yibo.cai@csr.com>
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/sirf/clk-atlas7.c
patch
|
blob
|
blame
|
history
diff --git
a/drivers/clk/sirf/clk-atlas7.c
b/drivers/clk/sirf/clk-atlas7.c
index 07b970ff50f13840e55a8188332b7e8de1af051d..ed77fd51692cbf670ded390e58e489d2b8d7ab7a 100644
(file)
--- a/
drivers/clk/sirf/clk-atlas7.c
+++ b/
drivers/clk/sirf/clk-atlas7.c
@@
-519,7
+519,7
@@
static unsigned long dto_clk_recalc_rate(struct clk_hw *hw,
static long dto_clk_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *parent_rate)
{
- u64 dividend = rate * (1 << 29);
+ u64 dividend =
(u64)
rate * (1 << 29);
do_div(dividend, *parent_rate);
dividend *= *parent_rate;
@@
-531,7
+531,7
@@
static long dto_clk_round_rate(struct clk_hw *hw, unsigned long rate,
static int dto_clk_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
- u64 dividend = rate * (1 << 29);
+ u64 dividend =
(u64)
rate * (1 << 29);
struct clk_dto *clk = to_dtoclk(hw);
do_div(dividend, parent_rate);