Received: from mail.onstor.com (66.201.51.107) by exch1.onstor.net
 (10.0.0.225) with Microsoft SMTP Server id 8.1.311.2; Thu, 2 Apr 2009
 10:42:14 -0700
Received: from psmtp.com ([64.18.0.161]) by mail.onstor.com with Microsoft
 SMTPSVC(6.0.3790.3959);	 Thu, 2 Apr 2009 10:41:46 -0700
Received: from source ([213.58.128.207]) by exprod5mx241.postini.com
 ([64.18.4.13]) with SMTP;	Thu, 02 Apr 2009 12:41:45 CDT
Received: from localhost.localdomain ([127.0.0.1]:22941 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP	id S20030680AbZDBQCA
 (ORCPT <rfc822;andy.sharp@onstor.com>);	Thu, 2 Apr 2009 17:02:00 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 02 Apr 2009 17:01:43
 +0100 (BST)
Received: from mba.ocn.ne.jp ([122.1.235.107]:20699 "HELO smtp.mba.ocn.ne.jp")
	by ftp.linux-mips.org with SMTP id S20030761AbZDBQBY (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 2 Apr 2009 17:01:24 +0100
Received: from localhost.localdomain (p2240-ipad309funabasi.chiba.ocn.ne.jp
 [123.217.196.240])	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP	id 3B783A7D1;
 Fri,  3 Apr 2009 01:01:17 +0900 (JST)
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
CC: "ralf@linux-mips.org" <ralf@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Thu, 2 Apr 2009 09:01:21 -0700
Subject: [PATCH] TXx9: Fix possible overflow in clock calculations
Thread-Topic: [PATCH] TXx9: Fix possible overflow in clock calculations
Thread-Index: AcmzulxCcs86TZb4SN6j5DdQq1FXow==
Message-ID: <1238688081-6329-1-git-send-email-anemo@mba.ocn.ne.jp>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 0b
X-MS-Exchange-Organization-AuthSource: exch1.onstor.net
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-originalarrivaltime: 02 Apr 2009 17:41:46.0663 (UTC)
 FILETIME=[4B5FD370:01C9B3BA]
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:59.39440/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-neptune: 0/0/0.00/0
x-ems-proccessed: 2K3Xl1OQTInXD6xxuA8z3Q==
x-ems-stamp: E5okLNh2Rczl0jjjpItznQ==
x-list: linux-mips
x-archive-position: 22247
x-ecartis-version: Ecartis v1.0.0
x-original-sender: anemo@mba.ocn.ne.jp
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

Addition of -fwrapv option in 2.6.29 discloses possible overflow with
signed arithmetics.  For example, result of "a * 6 / 12" (int a =3D
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>
---
 arch/mips/txx9/generic/setup_tx4927.c |    2 +-
 arch/mips/txx9/generic/setup_tx4938.c |    2 +-
 arch/mips/txx9/generic/setup_tx4939.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/txx9/generic/setup_tx4927.c b/arch/mips/txx9/generic=
/setup_tx4927.c
index 778078a..6b681cd 100644
--- a/arch/mips/txx9/generic/setup_tx4927.c
+++ b/arch/mips/txx9/generic/setup_tx4927.c
@@ -89,7 +89,7 @@ void __init tx4927_setup(void)
 {
 	int i;
 	__u32 divmode;
-	int cpuclk =3D 0;
+	unsigned int cpuclk =3D 0;
 	u64 ccfg;
=20
 	txx9_reg_res_init(TX4927_REV_PCODE(), TX4927_REG_BASE,
diff --git a/arch/mips/txx9/generic/setup_tx4938.c b/arch/mips/txx9/generic=
/setup_tx4938.c
index 5d2cbbf..b2b8529 100644
--- a/arch/mips/txx9/generic/setup_tx4938.c
+++ b/arch/mips/txx9/generic/setup_tx4938.c
@@ -94,7 +94,7 @@ void __init tx4938_setup(void)
 {
 	int i;
 	__u32 divmode;
-	int cpuclk =3D 0;
+	unsigned int cpuclk =3D 0;
 	u64 ccfg;
=20
 	txx9_reg_res_init(TX4938_REV_PCODE(), TX4938_REG_BASE,
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic=
/setup_tx4939.c
index d48eee1..f0beba8 100644
--- a/arch/mips/txx9/generic/setup_tx4939.c
+++ b/arch/mips/txx9/generic/setup_tx4939.c
@@ -115,7 +115,7 @@ void __init tx4939_setup(void)
 	int i;
 	__u32 divmode;
 	__u64 pcfg;
-	int cpuclk =3D 0;
+	unsigned int cpuclk =3D 0;
=20
 	txx9_reg_res_init(TX4939_REV_PCODE(), TX4939_REG_BASE,
 			  TX4939_REG_SIZE);
--=20
1.5.6.3


