MIPS: FW: Use kstrtoul() to parse unsigned long from the fw environment
authorAlban Bedel <albeu@free.fr>
Sat, 8 Nov 2014 11:39:39 +0000 (12:39 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Mon, 24 Nov 2014 06:45:26 +0000 (07:45 +0100)
Fix some value corruptions with values that can't be represented in a
signed long.

Signed-off-by: Alban Bedel <albeu@free.fr>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/8358/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/fw/lib/cmdline.c

index a0c361e6a5d2d642a20e9d1728dce51b8c0469a4..6ecda64ad18423f5e27e22cf9ccf8786a5062cac 100644 (file)
@@ -88,13 +88,13 @@ unsigned long fw_getenvl(char *envname)
 {
        unsigned long envl = 0UL;
        char *str;
-       long val;
        int tmp;
 
        str = fw_getenv(envname);
        if (str) {
-               tmp = kstrtol(str, 0, &val);
-               envl = (unsigned long)val;
+               tmp = kstrtoul(str, 0, &envl);
+               if (tmp)
+                       envl = 0;
        }
 
        return envl;