* [PATCH] m68k: sun3: Add check for __pgd_alloc()
@ 2025-02-17 16:00 Haoxiang Li
2025-02-18 8:18 ` Geert Uytterhoeven
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2025-02-17 16:00 UTC (permalink / raw)
To: sammy, geert, zhengqi.arch, akpm, dave.hansen, kevin.brodsky
Cc: linux-m68k, linux-kernel, Haoxiang Li, stable
Add check for the return value of __pgd_alloc() in
pgd_alloc() to prevent null pointer dereference.
Fixes: a9b3c355c2e6 ("asm-generic: pgalloc: provide generic __pgd_{alloc,free}")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
arch/m68k/include/asm/sun3_pgalloc.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/m68k/include/asm/sun3_pgalloc.h b/arch/m68k/include/asm/sun3_pgalloc.h
index f1ae4ed890db..80afc3a18724 100644
--- a/arch/m68k/include/asm/sun3_pgalloc.h
+++ b/arch/m68k/include/asm/sun3_pgalloc.h
@@ -44,8 +44,10 @@ static inline pgd_t * pgd_alloc(struct mm_struct *mm)
pgd_t *new_pgd;
new_pgd = __pgd_alloc(mm, 0);
- memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
- memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT));
+ if (likely(new_pgd != NULL)) {
+ memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
+ memset(new_pgd, 0, (PAGE_OFFSET >> PGDIR_SHIFT));
+ }
return new_pgd;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] m68k: sun3: Add check for __pgd_alloc()
2025-02-17 16:00 [PATCH] m68k: sun3: Add check for __pgd_alloc() Haoxiang Li
@ 2025-02-18 8:18 ` Geert Uytterhoeven
0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2025-02-18 8:18 UTC (permalink / raw)
To: Haoxiang Li
Cc: sammy, zhengqi.arch, akpm, dave.hansen, kevin.brodsky, linux-m68k,
linux-kernel, stable
On Mon, 17 Feb 2025 at 17:00, Haoxiang Li <haoxiang_li2024@163.com> wrote:
> Add check for the return value of __pgd_alloc() in
> pgd_alloc() to prevent null pointer dereference.
>
> Fixes: a9b3c355c2e6 ("asm-generic: pgalloc: provide generic __pgd_{alloc,free}")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
As akpm has already taken this:
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-18 8:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-17 16:00 [PATCH] m68k: sun3: Add check for __pgd_alloc() Haoxiang Li
2025-02-18 8:18 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).