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

From: Pekka J Enberg
Date: Mon Mar 19 2007 - 13:31:44 EST


On Mon, 19 Mar 2007, Christoph Lameter wrote:
> Hmmm.. kmem_cache_free is significantly different. One also needs to
> specify the slab cache.

No, it really isn't. Why would we want kfree() to be special? It's only
going to confuse people which results in bugs.

On Mon, 19 Mar 2007, Christoph Lameter wrote:
> Could we fix the BUG instead?

Yes, it should be fixed. But we still have a problem with block layer
(and probably others) passing NULL to mempool_free. But where should we
fix it if not slab? Is the problem ih bio_alloc_bioset() in fs/bio.c as
it's leaving a ->bi_io_vec NULL? Or is it in bio_free() forgetting to
check for NULL? Or maybe in mempool_free() in mm/mempool.c? It gets messy
real quick because you do need to be able to say "this data is optional."
Furthemore, the NULL sematics of kfree() are also useful for error
handling.

It's much safer to deal with this at slab level so why leave it out?

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/