bql: Fix POSDIFF() to integer overflow aware.
authorHiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Wed, 30 May 2012 12:24:39 +0000 (12:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 31 May 2012 22:18:16 +0000 (18:18 -0400)
POSDIFF() fails to take into account integer overflow case.

Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Denys Fedoryshchenko <denys@visp.net.lb>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/dynamic_queue_limits.c

index 6ab4587d052b5994f3be952b732bfc5a613664f9..c87eb76f2fd4f0e778ea74a915a0108e5202f8ce 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/jiffies.h>
 #include <linux/dynamic_queue_limits.h>
 
-#define POSDIFF(A, B) ((A) > (B) ? (A) - (B) : 0)
+#define POSDIFF(A, B) ((int)((A) - (B)) > 0 ? (A) - (B) : 0)
 
 /* Records completed count and recalculates the queue limit */
 void dql_completed(struct dql *dql, unsigned int count)