mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: <linux-kernel@vger.kernel.org>
Cc: "'Andrew Morton'" <akpm@osdl.org>
Subject: Bug fix in slab.c:alloc_arraycache
Date: Tue, 8 Mar 2005 19:13:50 -0800	[thread overview]
Message-ID: <200503090313.j293Dog17032@unix-os.sc.intel.com> (raw)

Kmem_cache_alloc_node is not capable of handling a null cachep
pointer as its input argument.

If I try to increase a slab limit by echoing a very large number
into /proc/slabinfo, kernel will panic from alloc_arraycache()
because Kmem_find_general_cachep() can actually return a NULL
pointer if the size argument is sufficiently large.

Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>


--- linux-2.6.11/mm/slab.c	Mon Oct 18 14:55:43 2004
+++ linux-2.6.11.ken/mm/slab.c	Tue Mar  1 19:14:07 2005
@@ -643,8 +645,10 @@
 	struct array_cache *nc = NULL;

 	if (cpu != -1) {
-		nc = kmem_cache_alloc_node(kmem_find_general_cachep(memsize,
-					GFP_KERNEL), cpu_to_node(cpu));
+		kmem_cache_t * cachep;
+		cachep = kmem_find_general_cachep(memsize, GFP_KERNEL);
+		if (cachep)
+			nc = kmem_cache_alloc_node(cachep, cpu_to_node(cpu));
 	}
 	if (!nc)
 		nc = kmalloc(memsize, GFP_KERNEL);



                 reply	other threads:[~2005-03-09  3:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200503090313.j293Dog17032@unix-os.sc.intel.com \
    --to=kenneth.w.chen@intel.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®