From: Alban Bedel Date: Sat, 8 Nov 2014 11:39:39 +0000 (+0100) Subject: MIPS: FW: Use kstrtoul() to parse unsigned long from the fw environment X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=484c344985ddf8e9ed12b8cf540eba0b1d869236;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git MIPS: FW: Use kstrtoul() to parse unsigned long from the fw environment Fix some value corruptions with values that can't be represented in a signed long. Signed-off-by: Alban Bedel 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 --- diff --git a/arch/mips/fw/lib/cmdline.c b/arch/mips/fw/lib/cmdline.c index a0c361e6a5d2..6ecda64ad184 100644 --- a/arch/mips/fw/lib/cmdline.c +++ b/arch/mips/fw/lib/cmdline.c @@ -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;