watchdog: w83977f_wdt: underflow in wdt_set_timeout()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 6 Nov 2015 09:56:31 +0000 (12:56 +0300)
committerWim Van Sebroeck <wim@iguana.be>
Mon, 23 Nov 2015 07:59:30 +0000 (08:59 +0100)
"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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/w83977f_wdt.c

index 91bf55a2002497eca6de68258515484ba9f13efa..20e2bba10400910cfbd86a68d3d6f988b9d77dec 100644 (file)
@@ -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.