linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Rick Lindsley <ricklind@linux.vnet.ibm.com>
To: Michael Ellerman <michaele@au1.ibm.com>, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc/book3s/64: check for NULL pointer in pgd_alloc()
Date: Sun, 5 May 2019 17:20:43 -0700	[thread overview]
Message-ID: <5ae0401c-a84a-1e59-5d9d-70659f5a85de@linux.vnet.ibm.com> (raw)

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


             reply	other threads:[~2019-05-06  0:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06  0:20 Rick Lindsley [this message]
2019-05-06 11:33 ` [PATCH] powerpc/book3s/64: check for NULL pointer in pgd_alloc() Michael Ellerman
2019-05-06 16:43   ` Rick Lindsley
2019-05-09 15:34 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ae0401c-a84a-1e59-5d9d-70659f5a85de@linux.vnet.ibm.com \
    --to=ricklind@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=michaele@au1.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).