Skip to contentSkip to conversation

UBIFS: Fix integer overflow warnings

PATCH In review Kevin Cernekee 2 participants 2 messages Jun 27, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 UBIFS: Fix integer overflow warnings

This warning was observed on MIPS32 using 2.6.31-rc1 and gcc-4.2.0:

fs/ubifs/io.c: In function 'ubifs_wbuf_init':
fs/ubifs/io.c:860: warning: integer overflow in expression fs/ubifs/io.c:860: warning: integer overflow in expression fs/ubifs/io.c:860: warning: integer overflow in expression

---
index bc58571..184157e 100644

fs/ubifs/io.c +2 -1
@@ -857,7 +857,8 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf)
 	 * and hard limits.
 	 */
 	hardlimit = ktime_set(DEFAULT_WBUF_TIMEOUT_SECS, 0);
-	wbuf->delta = (DEFAULT_WBUF_TIMEOUT_SECS * NSEC_PER_SEC) * 2 / 10;
+	wbuf->delta = ((unsigned long long)DEFAULT_WBUF_TIMEOUT_SECS *
+		       NSEC_PER_SEC) * 2 / 10;
 	wbuf->softlimit = ktime_sub_ns(hardlimit, wbuf->delta);
 	hrtimer_set_expires_range_ns(&wbuf->timer,  wbuf->softlimit,
 				     wbuf->delta);

--

#1 lore raw
Quoted 8 lines · Kevin Cernekee

This warning was observed on MIPS32 using 2.6.31-rc1 and gcc-4.2.0:

fs/ubifs/io.c: In function 'ubifs_wbuf_init':
fs/ubifs/io.c:860: warning: integer overflow in expression fs/ubifs/io.c:860: warning: integer overflow in expression fs/ubifs/io.c:860: warning: integer overflow in expression

Thanks for the patch,

however we there is already a fix for this. I'll send it to Linus soon.

http://git.infradead.org/ubifs-2.6.git?a=commit;h=4804e8b700504978eb4b9397f818ba7ba1227a15

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)