Skip to content

Commit

Permalink
MIPS: TXx9: Fix possible overflow in clock calculations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Atsushi Nemoto authored and Ralf Baechle committed May 14, 2009
1 parent 4f29c05 commit 740ebe4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arch/mips/txx9/generic/setup_tx4927.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void __init tx4927_setup(void)
{
int i;
__u32 divmode;
int cpuclk = 0;
unsigned int cpuclk = 0;
u64 ccfg;

txx9_reg_res_init(TX4927_REV_PCODE(), TX4927_REG_BASE,
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/txx9/generic/setup_tx4938.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void __init tx4938_setup(void)
{
int i;
__u32 divmode;
int cpuclk = 0;
unsigned int cpuclk = 0;
u64 ccfg;

txx9_reg_res_init(TX4938_REV_PCODE(), TX4938_REG_BASE,
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/txx9/generic/setup_tx4939.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void __init tx4939_setup(void)
int i;
__u32 divmode;
__u64 pcfg;
int cpuclk = 0;
unsigned int cpuclk = 0;

txx9_reg_res_init(TX4939_REV_PCODE(), TX4939_REG_BASE,
TX4939_REG_SIZE);
Expand Down

0 comments on commit 740ebe4

Please sign in to comment.