Skip to content

Commit 7277dd0

Browse files
Haoxiang Liakpm00
authored andcommitted
m68k: sun3: add check for __pgd_alloc()
Add check for the return value of __pgd_alloc() in pgd_alloc() to prevent null pointer dereference. Link: https://lkml.kernel.org/r/[email protected] Fixes: a9b3c35 ("asm-generic: pgalloc: provide generic __pgd_{alloc,free}") Signed-off-by: Haoxiang Li <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Kevin Brodsky <[email protected]> Cc: Qi Zheng <[email protected]> Cc: Sam Creasey <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 349db08 commit 7277dd0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/m68k/include/asm/sun3_pgalloc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ static inline pgd_t * pgd_alloc(struct mm_struct *mm)
4444
pgd_t *new_pgd;
4545

4646
new_pgd = __pgd_alloc(mm, 0);
47-
memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
48-
memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT));
47+
if (likely(new_pgd != NULL)) {
48+
memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
49+
memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT));
50+
}
4951
return new_pgd;
5052
}
5153

0 commit comments

Comments
 (0)