Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: TXx9: Fix possible overflow in clock calculations

Addition of -fwrapv option in 2.6.29 discloses possible overflow with
signed arithmetics. For example, result of "a * 6 / 12" (int a =
400000000) is 200000000 without -fwrapv but -157913941 with -fwrapv.

Change some variable to unsigned to avoid such overflows.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Atsushi Nemoto and committed by
Ralf Baechle
740ebe4a 4f29c057

+3 -3
+1 -1
arch/mips/txx9/generic/setup_tx4927.c
··· 88 88 { 89 89 int i; 90 90 __u32 divmode; 91 - int cpuclk = 0; 91 + unsigned int cpuclk = 0; 92 92 u64 ccfg; 93 93 94 94 txx9_reg_res_init(TX4927_REV_PCODE(), TX4927_REG_BASE,
+1 -1
arch/mips/txx9/generic/setup_tx4938.c
··· 93 93 { 94 94 int i; 95 95 __u32 divmode; 96 - int cpuclk = 0; 96 + unsigned int cpuclk = 0; 97 97 u64 ccfg; 98 98 99 99 txx9_reg_res_init(TX4938_REV_PCODE(), TX4938_REG_BASE,
+1 -1
arch/mips/txx9/generic/setup_tx4939.c
··· 114 114 int i; 115 115 __u32 divmode; 116 116 __u64 pcfg; 117 - int cpuclk = 0; 117 + unsigned int cpuclk = 0; 118 118 119 119 txx9_reg_res_init(TX4939_REV_PCODE(), TX4939_REG_BASE, 120 120 TX4939_REG_SIZE);