--- linux-2.6.16.9/include/linux/slab.h 2006-04-19 08:10:14.000000000 +0200 +++ linux-2.6.16.9-kfree/include/linux/slab.h 2006-04-27 11:19:00.000000000 +0200 @@ -123,7 +123,18 @@ return kzalloc(n * size, flags); } -extern void kfree(const void *); +extern void __kfree(const void *); + +static inline void kfree(const void *ptr) +{ + if (__builtin_constant_p(ptr==NULL)) { + if (ptr) + __kfree(ptr); + } else { + __kfree(ptr); + } +} + extern unsigned int ksize(const void *); #ifdef CONFIG_NUMA --- linux-2.6.16.9/mm/slab.c 2006-04-27 11:24:38.000000000 +0200 +++ linux-2.6.16.9-kfree/mm/slab.c 2006-04-27 11:17:06.000000000 +0200 @@ -3267,7 +3267,7 @@ EXPORT_SYMBOL(kmem_cache_free); /** - * kfree - free previously allocated memory + * __kfree - free previously allocated memory * @objp: pointer returned by kmalloc. * * If @objp is NULL, no operation is performed. @@ -3275,7 +3275,7 @@ * Don't free memory not originally allocated by kmalloc() * or you will run into trouble. */ -void kfree(const void *objp) +void __kfree(const void *objp) { struct kmem_cache *c; unsigned long flags;