[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0703191022310.8671@sbz-30.cs.Helsinki.FI>
Date: Mon, 19 Mar 2007 10:27:18 +0200 (EET)
From: Pekka J Enberg <penberg@...helsinki.fi>
To: akpm@...ux-foundation.org
cc: ast@...dv.de, clameter@....com, linux-kernel@...r.kernel.org
Subject: [PATCH] slab: deal with NULL pointers passed to kmem_cache_free
From: Pekka Enberg <penberg@...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@...dv.de>
Cc: Christoph Lameter <clameter@....com>
Signed-off-by: Pekka Enberg <penberg@...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);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists