diff options
author | Markos Chandras <markos.chandras@imgtec.com> | 2014-08-18 10:04:11 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-08-19 07:30:47 -0400 |
commit | 64615682658373516863b5b5971ff1d922d0ae7b (patch) | |
tree | 5d7960bd0cadbdbea4d546bf6baa40f6f4073697 /arch/mips | |
parent | 293076f300f52e1593b596b3f09ec057ee6e4a36 (diff) |
MIPS: Malta: Improve system memory detection for '{e, }memsize' >= 2G
Using kstrtol to parse the "{e,}memsize" variables was wrong because this
parses signed long numbers. In case of '{e,}memsize' >= 2G, the top bit
is set, resulting to -ERANGE errors and possibly random system memory
boundaries. We fix this by replacing "kstrtol" with "kstrtoul".
We also improve the code to check the kstrtoul return value and
print a warning if an error was returned.
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: <stable@vger.kernel.org> # v3.15+
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7543/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/mti-malta/malta-memory.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/mips/mti-malta/malta-memory.c b/arch/mips/mti-malta/malta-memory.c index 0c35dee0a215..8fddd2cdbff7 100644 --- a/arch/mips/mti-malta/malta-memory.c +++ b/arch/mips/mti-malta/malta-memory.c | |||
@@ -35,13 +35,19 @@ fw_memblock_t * __init fw_getmdesc(int eva) | |||
35 | /* otherwise look in the environment */ | 35 | /* otherwise look in the environment */ |
36 | 36 | ||
37 | memsize_str = fw_getenv("memsize"); | 37 | memsize_str = fw_getenv("memsize"); |
38 | if (memsize_str) | 38 | if (memsize_str) { |
39 | tmp = kstrtol(memsize_str, 0, &memsize); | 39 | tmp = kstrtoul(memsize_str, 0, &memsize); |
40 | if (tmp) | ||
41 | pr_warn("Failed to read the 'memsize' env variable.\n"); | ||
42 | } | ||
40 | if (eva) { | 43 | if (eva) { |
41 | /* Look for ememsize for EVA */ | 44 | /* Look for ememsize for EVA */ |
42 | ememsize_str = fw_getenv("ememsize"); | 45 | ememsize_str = fw_getenv("ememsize"); |
43 | if (ememsize_str) | 46 | if (ememsize_str) { |
44 | tmp = kstrtol(ememsize_str, 0, &ememsize); | 47 | tmp = kstrtoul(ememsize_str, 0, &ememsize); |
48 | if (tmp) | ||
49 | pr_warn("Failed to read the 'ememsize' env variable.\n"); | ||
50 | } | ||
45 | } | 51 | } |
46 | if (!memsize && !ememsize) { | 52 | if (!memsize && !ememsize) { |
47 | pr_warn("memsize not set in YAMON, set to default (32Mb)\n"); | 53 | pr_warn("memsize not set in YAMON, set to default (32Mb)\n"); |