Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Alban Bedel and committed by
Ralf Baechle
484c3449 4a792e56

+3 -3
+3 -3
arch/mips/fw/lib/cmdline.c
··· 88 88 { 89 89 unsigned long envl = 0UL; 90 90 char *str; 91 - long val; 92 91 int tmp; 93 92 94 93 str = fw_getenv(envname); 95 94 if (str) { 96 - tmp = kstrtol(str, 0, &val); 97 - envl = (unsigned long)val; 95 + tmp = kstrtoul(str, 0, &envl); 96 + if (tmp) 97 + envl = 0; 98 98 } 99 99 100 100 return envl;