Messages in this thread |  | | Date | Mon, 19 Mar 2007 16:44:14 -0500 | | From | Matt Mackall <> | | Subject | Re: [PATCH] slab: deal with NULL pointers passed to kmem_cache_free |
| |
On Mon, Mar 19, 2007 at 02:16:01PM -0700, Christoph Lameter wrote: > On Mon, 19 Mar 2007, Matt Mackall wrote: > > > I think this sort of thing should work: > > > > a = kmalloc(...) > > b = kmem_cache_alloc(..) > > c = allocate_some_id(...) > > if (!a || !b || !c) { > > free_some_id(c) > > kmem_cache_free(c) > > ^^^^ this requires the specification of a kmem_cache structure and the > object must be allocated by that cache.
Yes, omitted for brevity.
> > kfree(a); > > Here we dynamically determine the slab cache and do not verify even which > slab it came from.
That's an implementation detail that you shouldn't rely on and that SLOB in fact breaks. kfree(kmem_cache_alloc(...)) is bad style to the point of being a bug.
In my opinion:
xxxfree(xxxalloc(...)); /* should always work, even if allocation fails */ yyyfree(xxxalloc(...)); /* should never be expected to work */
-- Mathematics is the supreme nostalgia of our time. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |