aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.m@jp.panasonic.com>2015-01-19 22:38:25 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2015-01-21 10:52:40 -0500
commit909ba297beb50981a9d12364688d3c5f3084c6eb (patch)
tree14080141f5359248a3f08b420dd8f56a666d61f0 /arch
parent2d9ed7406fd24987b75f78fea8290202d8108f34 (diff)
ARM: 8292/1: mm: fix size rounding-down of arm_add_memory() function
The current rounding of "size" is wrong: - If "start" is sufficiently near the next page boundary, "size" is decremented by more than enough and the last page is lost. - If "size" is sufficiently small, it is wrapped around and gets a bogus value. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/kernel/setup.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index f9c863911038..d13f185e7bd5 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -657,10 +657,13 @@ int __init arm_add_memory(u64 start, u64 size)
657 657
658 /* 658 /*
659 * Ensure that start/size are aligned to a page boundary. 659 * Ensure that start/size are aligned to a page boundary.
660 * Size is appropriately rounded down, start is rounded up. 660 * Size is rounded down, start is rounded up.
661 */ 661 */
662 size -= start & ~PAGE_MASK;
663 aligned_start = PAGE_ALIGN(start); 662 aligned_start = PAGE_ALIGN(start);
663 if (aligned_start > start + size)
664 size = 0;
665 else
666 size -= aligned_start - start;
664 667
665#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT 668#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT
666 if (aligned_start > ULONG_MAX) { 669 if (aligned_start > ULONG_MAX) {