[PATCH 5/5] powerpc/32: reuse orphaned memblocks in kasan_init_shadow_page_tables()

From: Christophe Leroy
Date: Tue Jan 14 2020 - 12:54:14 EST


If concurrent PMD population has happened, re-use orphaned memblocks.

Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxx>
---
arch/powerpc/mm/kasan/kasan_init_32.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c
index c4bf9ed04f88..d3cacd462560 100644
--- a/arch/powerpc/mm/kasan/kasan_init_32.c
+++ b/arch/powerpc/mm/kasan/kasan_init_32.c
@@ -34,17 +34,17 @@ static int __init kasan_init_shadow_page_tables(unsigned long k_start, unsigned
{
pmd_t *pmd;
unsigned long k_cur, k_next;
+ pte_t *new = NULL;

pmd = pmd_offset(pud_offset(pgd_offset_k(k_start), k_start), k_start);

for (k_cur = k_start; k_cur != k_end; k_cur = k_next, pmd++) {
- pte_t *new;
-
k_next = pgd_addr_end(k_cur, k_end);
if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte)
continue;

- new = memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE);
+ if (!new)
+ new = memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE);

if (!new)
return -ENOMEM;
--
2.13.3