From: Mika Penttilä Date: Tue, 15 Mar 2016 21:56:45 +0000 (-0700) Subject: mm/memory.c: make apply_to_page_range() more robust X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9cb65bc3b1114004e2ccee5939031325c7bf16e8;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git mm/memory.c: make apply_to_page_range() more robust Arm and arm64 used to trigger this BUG_ON() - this has now been fixed. But a WARN_ON() here is sufficient to catch future buggy callers. Signed-off-by: Mika Penttilä Reviewed-by: Pekka Enberg Acked-by: David Rientjes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memory.c b/mm/memory.c index 8132787ae4d5..8adb5b756264 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1876,7 +1876,9 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr, unsigned long end = addr + size; int err; - BUG_ON(addr >= end); + if (WARN_ON(addr >= end)) + return -EINVAL; + pgd = pgd_offset(mm, addr); do { next = pgd_addr_end(addr, end);