linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/book3s/64: check for NULL pointer in pgd_alloc()
@ 2019-05-06  0:20 Rick Lindsley
  2019-05-06 11:33 ` Michael Ellerman
  2019-05-09 15:34 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Rick Lindsley @ 2019-05-06  0:20 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev

When the memset code was added to pgd_alloc(), it failed to consider that kmem_cache_alloc() can return NULL.  It's uncommon, but not impossible under heavy memory contention.

Signed-off-by: Rick Lindsley <ricklind@vnet.linux.ibm.com>
Fixes: cf266dbcd2a7 ("Zero PGD pages on allocation")

--- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
+++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
@@ -81,6 +81,10 @@ static inline pgd_t *pgd_alloc(struct mm
  
	pgd = kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
			       pgtable_gfp_flags(mm, GFP_KERNEL));
+
+	if (unlikely(!pgd))
+		return pgd;
+
	/*
	 * Don't scan the PGD for pointers, it contains references to PUDs but
	 * those references are not full pointers and so can't be recognised by


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-09 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-06  0:20 [PATCH] powerpc/book3s/64: check for NULL pointer in pgd_alloc() Rick Lindsley
2019-05-06 11:33 ` Michael Ellerman
2019-05-06 16:43   ` Rick Lindsley
2019-05-09 15:34 ` Michael Ellerman

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).