Thread (16 messages) 16 messages, 2 authors, 2012-08-02

Re: Common [2/9] slub: Use kmem_cache for the kmem_cache structure

From: Glauber Costa <hidden>
Date: 2012-08-01 08:44:58

On 07/31/2012 09:36 PM, Christoph Lameter wrote:
Do not use kmalloc() but kmem_cache_alloc() for the allocation
of the kmem_cache structures in slub.

This is the way its supposed to be. Recent merges lost
the freeing of the kmem_cache structure and so this is also
fixing memory leak on kmem_cache_destroy() by adding
the missing free action to sysfs_slab_remove().
This patch seems incomplete to say the least.

1) You are still not touching the !SYSFS version of the function,
that still reads:

static inline void sysfs_slab_remove(struct kmem_cache *s)
{
        kfree(s->name);
        kfree(s);
}

and it is then inconsistent with its SYSFS version.

2) kmem_cache_release still reads:

static void kmem_cache_release(struct kobject *kobj)
{
        struct kmem_cache *s = to_slab(kobj);

        kfree(s->name);
        kfree(s);
}

Since IIRC both kmem_cache_release and sysfs_slab_remove are called
during cache destruction, you now have a double-double-free (a quadruple
free?)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help