]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.16.3/mips-malta-improve-system-memory-detection-for-e-memsize-2g.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / mips-malta-improve-system-memory-detection-for-e-memsize-2g.patch
1 From 64615682658373516863b5b5971ff1d922d0ae7b Mon Sep 17 00:00:00 2001
2 From: Markos Chandras <markos.chandras@imgtec.com>
3 Date: Mon, 18 Aug 2014 15:04:11 +0100
4 Subject: MIPS: Malta: Improve system memory detection for '{e, }memsize' >= 2G
5
6 From: Markos Chandras <markos.chandras@imgtec.com>
7
8 commit 64615682658373516863b5b5971ff1d922d0ae7b upstream.
9
10 Using kstrtol to parse the "{e,}memsize" variables was wrong because this
11 parses signed long numbers. In case of '{e,}memsize' >= 2G, the top bit
12 is set, resulting to -ERANGE errors and possibly random system memory
13 boundaries. We fix this by replacing "kstrtol" with "kstrtoul".
14 We also improve the code to check the kstrtoul return value and
15 print a warning if an error was returned.
16
17 Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
18 Cc: linux-mips@linux-mips.org
19 Patchwork: https://patchwork.linux-mips.org/patch/7543/
20 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 arch/mips/mti-malta/malta-memory.c | 14 ++++++++++----
25 1 file changed, 10 insertions(+), 4 deletions(-)
26
27 --- a/arch/mips/mti-malta/malta-memory.c
28 +++ b/arch/mips/mti-malta/malta-memory.c
29 @@ -34,13 +34,19 @@ fw_memblock_t * __init fw_getmdesc(int e
30 /* otherwise look in the environment */
31
32 memsize_str = fw_getenv("memsize");
33 - if (memsize_str)
34 - tmp = kstrtol(memsize_str, 0, &memsize);
35 + if (memsize_str) {
36 + tmp = kstrtoul(memsize_str, 0, &memsize);
37 + if (tmp)
38 + pr_warn("Failed to read the 'memsize' env variable.\n");
39 + }
40 if (eva) {
41 /* Look for ememsize for EVA */
42 ememsize_str = fw_getenv("ememsize");
43 - if (ememsize_str)
44 - tmp = kstrtol(ememsize_str, 0, &ememsize);
45 + if (ememsize_str) {
46 + tmp = kstrtoul(ememsize_str, 0, &ememsize);
47 + if (tmp)
48 + pr_warn("Failed to read the 'ememsize' env variable.\n");
49 + }
50 }
51 if (!memsize && !ememsize) {
52 pr_warn("memsize not set in YAMON, set to default (32Mb)\n");