summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm/kasan/kasan_init_32.c
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2020-05-19 05:48:43 +0000
committerMichael Ellerman <mpe@ellerman.id.au>2020-05-20 23:41:01 +1000
commitd132443a73d7a131775df46f33000f67ed92de1e (patch)
tree454c60479119fd5aa6197dd0d2a6d0a45316d625 /arch/powerpc/mm/kasan/kasan_init_32.c
parent30df74d67d48949da87e3a5b57c381763e8fd526 (diff)
downloadlinux-stable-d132443a73d7a131775df46f33000f67ed92de1e.tar.gz
linux-stable-d132443a73d7a131775df46f33000f67ed92de1e.tar.bz2
linux-stable-d132443a73d7a131775df46f33000f67ed92de1e.zip
powerpc/kasan: Fix error detection on memory allocation
In case (k_start & PAGE_MASK) doesn't equal (kstart), 'va' will never be NULL allthough 'block' is NULL Check the return of memblock_alloc() directly instead of the resulting address in the loop. Fixes: 509cd3f2b473 ("powerpc/32: Simplify KASAN init") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/7cb8ca82042bfc45a5cfe726c921cd7e7eeb12a3.1589866984.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch/powerpc/mm/kasan/kasan_init_32.c')
-rw-r--r--arch/powerpc/mm/kasan/kasan_init_32.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
index cbcad369fcb2..8b15fe09b967 100644
--- a/arch/powerpc/mm/kasan/kasan_init_32.c
+++ b/arch/powerpc/mm/kasan/kasan_init_32.c
@@ -76,15 +76,14 @@ static int __init kasan_init_region(void *start, size_t size)
return ret;
block = memblock_alloc(k_end - k_start, PAGE_SIZE);
+ if (!block)
+ return -ENOMEM;
for (k_cur = k_start & PAGE_MASK; k_cur < k_end; k_cur += PAGE_SIZE) {
pmd_t *pmd = pmd_ptr_k(k_cur);
void *va = block + k_cur - k_start;
pte_t pte = pfn_pte(PHYS_PFN(__pa(va)), PAGE_KERNEL);
- if (!va)
- return -ENOMEM;
-
__set_pte_at(&init_mm, k_cur, pte_offset_kernel(pmd, k_cur), pte, 0);
}
flush_tlb_kernel_range(k_start, k_end);