Skip to contentSkip to conversation

watchdog: w83977f_wdt: underflow in wdt_set_timeout()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 6, 2015

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

PATCH 1/1 watchdog: w83977f_wdt: underflow in wdt_set_timeout()

"t" is controlled by the user. If "t" is a very large integer then it could lead to a negative "tmrval". We cap the upper bound of "tmrval" but, in the current code, we allow negatives. This is a bug and it causes a static checker warning. Let's make "tmrval" unsigned to avoid this problem.

drivers/watchdog/w83977f_wdt.c +1 -1
index 91bf55a..20e2bba 100644
@@ -224,7 +224,7 @@ static int wdt_keepalive(void)
 
 static int wdt_set_timeout(int t)
 {
-	int tmrval;
+	unsigned int tmrval;
 
 	/*
 	 * Convert seconds to watchdog counter time units, rounding up.
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Dan Carpenter

"t" is controlled by the user. If "t" is a very large integer then it could lead to a negative "tmrval". We cap the upper bound of "tmrval" but, in the current code, we allow negatives. This is a bug and it causes a static checker warning. Let's make "tmrval" unsigned to avoid this problem.

Quoted 18 lines
drivers/watchdog/w83977f_wdt.c +1 -2
index 91bf55a..20e2bba 100644
@@ -224,7 +224,7 @@ static int wdt_keepalive(void)
 
  static int wdt_set_timeout(int t)
  {
-	int tmrval;
+	unsigned int tmrval;
 
  	/*
  	 * Convert seconds to watchdog counter time units, rounding up.
--

To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html