Re: [PATCH] slab: deal with NULL pointers passed to kmem_cache_free

From: Pekka Enberg
Date: Mon Mar 19 2007 - 17:25:54 EST



On 3/19/2007, "Andrew Morton" <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> Would prefer to do:
>
> static inline void kmem_cache_free_if_not_null(struct kmem_cache *cachep,
> void *objp)
> {
> if (objp)
> kmem_cache_free(cachep, objp);
> }
>
> so that we don't add extra overhead to all the thousands of existing,
> well-behaved callsites.

That bloats kernel text all the same so it's much cleaner to just make
the callers explicitly check for NULL then. That said, I'm sorry but I
just don't buy the "overhead" part of your argument since it's one
branch and no extra data cache pressure especially as we're already
doing the BUG_ON and page flag checking.

But, since you're NAKing my patch, we need to get the mempool for from
the original thread in to fix the oops.

Pekka
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/