public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] slab: deal with NULL pointers passed to kmem_cache_free
@ 2007-03-19  8:27 Pekka J Enberg
  2007-03-19 11:31 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Pekka J Enberg @ 2007-03-19  8:27 UTC (permalink / raw)
  To: akpm; +Cc: ast, clameter, linux-kernel

From: Pekka Enberg <penberg@cs.helsinki.fi>

This changes kmem_cache_free() to deal with NULL objects passed to it. The 
current behavior is inconsistent with kfree() so there are callers 
passing NULL to kmem_cache_free().

Andreas, can you please confirm this fixes the oops you reported on 
linux-scsi?

Cc: Andreas Steinmetz <ast@domdv.de>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 mm/slab.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: 2.6/mm/slab.c
===================================================================
--- 2.6.orig/mm/slab.c	2007-03-19 10:18:52.000000000 +0200
+++ 2.6/mm/slab.c	2007-03-19 10:19:42.000000000 +0200
@@ -3741,6 +3741,8 @@ EXPORT_SYMBOL(__kmalloc);
  * @cachep: The cache the allocation was from.
  * @objp: The previously allocated object.
  *
+ * If @objp is NULL, no operation is performed.
+ *
  * Free an object which was previously allocated from this
  * cache.
  */
@@ -3748,6 +3750,9 @@ void kmem_cache_free(struct kmem_cache *
 {
 	unsigned long flags;
 
+	if (unlikely(!objp))
+		return;
+
 	BUG_ON(virt_to_cache(objp) != cachep);
 
 	local_irq_save(flags);

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

end of thread, other threads:[~2007-03-21 18:32 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-19  8:27 [PATCH] slab: deal with NULL pointers passed to kmem_cache_free Pekka J Enberg
2007-03-19 11:31 ` Andrew Morton
2007-03-19 11:40   ` Pekka J Enberg
2007-03-19 17:08 ` Christoph Lameter
2007-03-19 17:31   ` Pekka J Enberg
2007-03-19 20:49   ` Matt Mackall
2007-03-19 21:10     ` Andrew Morton
2007-03-19 21:25       ` Pekka Enberg
2007-03-19 21:41         ` Andrew Morton
2007-03-19 21:49           ` Matt Mackall
2007-03-20  7:06           ` Pekka Enberg
2007-03-20 18:41             ` Christoph Lameter
2007-03-21 11:42               ` Pekka J Enberg
2007-03-20  7:14           ` Pekka Enberg
2007-03-20  7:39             ` Eric Dumazet
2007-03-20  7:47               ` Pekka J Enberg
2007-03-20  7:56                 ` Eric Dumazet
2007-03-21 10:11                 ` Jarek Poplawski
2007-03-21 12:13                   ` Pekka Enberg
2007-03-21 13:31                     ` Jarek Poplawski
2007-03-21 13:36                       ` Pekka J Enberg
2007-03-21 14:11                         ` Rafael J. Wysocki
2007-03-21 14:41                           ` Pekka Enberg
2007-03-21 16:30                             ` Andrew Morton
2007-03-21 17:54                               ` Jörn Engel
2007-03-21 18:32                               ` Pekka Enberg
2007-03-21 14:45                         ` Jarek Poplawski
2007-03-19 22:04       ` Jörn Engel
2007-03-19 21:16     ` Christoph Lameter
2007-03-19 21:44       ` Matt Mackall
2007-03-19 23:32 ` Andreas Steinmetz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox