Commit 7277dd0a authored by Haoxiang Li's avatar Haoxiang Li Committed by Andrew Morton
Browse files

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/20250217160017.2375536-1-haoxiang_li2024@163.com


Fixes: a9b3c355 ("asm-generic: pgalloc: provide generic __pgd_{alloc,free}")
Signed-off-by: default avatarHaoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Sam Creasey <sammy@sammy.net>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 349db086
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -44,8 +44,10 @@ static inline pgd_t * pgd_alloc(struct mm_struct *mm)
	pgd_t *new_pgd;

	new_pgd = __pgd_alloc(mm, 0);
	if (likely(new_pgd != NULL)) {
		memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
		memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT));
	}
	return new_pgd;
}