mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "ethan.zhao" <ethan.kernel@gmail.com>
To: hristoph@lameter.com, alokk@calsoftinc.com,
	shobhit@calsoftinc.com, shai@scalex86.org, cl@linux.com
Cc: linux-kernel@vger.kernel.org, "ethan.zhao" <ethan.kernel@gmail.com>
Subject: [PATCH] mm/slab.c: check pointer slabp before using it in alloc_slabmgmt()
Date: Sun,  8 Dec 2013 17:38:53 +0800	[thread overview]
Message-ID: <1386495533-413-1-git-send-email-ethan.kernel@gmail.com> (raw)

Move the NULL check of slabp to the right place before refer its memeber in
function alloc_slabmgmt().

This bug may be introduced by rewriting of funcion kmemleak_scan_area(),
the first parameter changed from slabp to &slabp->list.

Signed-off-by: ethan.zhao <ethan.kernel@gmail.com>
---
 mm/slab.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 2580db0..b6d27bc 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2612,6 +2612,8 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
 		/* Slab management obj is off-slab. */
 		slabp = kmem_cache_alloc_node(cachep->slabp_cache,
 					      local_flags, nodeid);
+		if (!slabp)
+			return NULL;
 		/*
 		 * If the first object in the slab is leaked (it's allocated
 		 * but no one has a reference to it), we want to make sure
@@ -2620,8 +2622,6 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
 		 */
 		kmemleak_scan_area(&slabp->list, sizeof(struct list_head),
 				   local_flags);
-		if (!slabp)
-			return NULL;
 	} else {
 		slabp = objp + colour_off;
 		colour_off += cachep->slab_size;
-- 
1.8.3.4 (Apple Git-47)


             reply	other threads:[~2013-12-08  9:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-08  9:38 ethan.zhao [this message]
2013-12-09 16:11 ` Christoph Lameter
2013-12-10  7:08   ` Ethan Zhao
2013-12-10  8:16     ` Ethan Zhao
2013-12-10 15:35       ` Christoph Lameter
2013-12-10 16:19         ` Peter Hurley
2013-12-14 11:15           ` Meelis Roos
2013-12-10 15:40 ` Christoph Lameter

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=1386495533-413-1-git-send-email-ethan.kernel@gmail.com \
    --to=ethan.kernel@gmail.com \
    --cc=alokk@calsoftinc.com \
    --cc=cl@linux.com \
    --cc=hristoph@lameter.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shai@scalex86.org \
    --cc=shobhit@calsoftinc.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

Powered by JetHome