LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Gen Zhang <blackgod016574@gmail.com>
To: cl@linux.com, penberg@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [Patch] slub: Fix a missing-check bug in mm/slub.c file of Linux 5.1.1
Date: Mon, 13 May 2019 22:18:31 +0800	[thread overview]
Message-ID: <20190513141831.GA9502@zhanggen-UX430UQ> (raw)

Pointer s is allocated with kmem_cache_zalloc(). And s is used in the 
follwoing codes. However, when kmem_cache_zalloc fails, using s will
cause null pointer dereference and the kernel will go wrong. Thus we 
check whether the kmem_cache_zalloc fails.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>

---
--- mm/slub.c
+++ mm/slub.c
@@ -4201,6 +4201,8 @@ static struct kmem_cache * __init bootst
 {
 	int node;
 	struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT);
+	if (!s)
+		return ERR_PTR(-ENOMEM);
 	struct kmem_cache_node *n;
 
 	memcpy(s, static_cache, kmem_cache->object_size);
---

             reply	other threads:[~2019-05-13 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13 14:18 Gen Zhang [this message]
2019-05-15  6:44 Gen Zhang
2019-05-19  4:43 ` David Rientjes

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=20190513141831.GA9502@zhanggen-UX430UQ \
    --to=blackgod016574@gmail.com \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@kernel.org \
    --subject='Re: [Patch] slub: Fix a missing-check bug in mm/slub.c file of Linux 5.1.1' \
    /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

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