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>
This commit is contained in:
parent
4a792e56cf
commit
484c344985
|
@ -88,13 +88,13 @@ unsigned long fw_getenvl(char *envname)
|
||||||
{
|
{
|
||||||
unsigned long envl = 0UL;
|
unsigned long envl = 0UL;
|
||||||
char *str;
|
char *str;
|
||||||
long val;
|
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
str = fw_getenv(envname);
|
str = fw_getenv(envname);
|
||||||
if (str) {
|
if (str) {
|
||||||
tmp = kstrtol(str, 0, &val);
|
tmp = kstrtoul(str, 0, &envl);
|
||||||
envl = (unsigned long)val;
|
if (tmp)
|
||||||
|
envl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return envl;
|
return envl;
|
||||||
|
|
Loading…
Reference in New Issue