Skip to content

Commit

Permalink
mm: remove broken 'kzalloc' mempool
Browse files Browse the repository at this point in the history
The kzalloc mempool zeros items when they are initially allocated, but
does not rezero used items that are returned to the pool.  Consequently
mempool_alloc()s may return non-zeroed memory.

Since there are/were only two in-tree users for
mempool_create_kzalloc_pool(), and 'fixing' this in a way that will
re-zero used (but not new) items before first use is non-trivial, just
remove it.

Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
liewegas authored and torvalds committed Sep 22, 2009
1 parent bbba809 commit bba7881
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
10 changes: 2 additions & 8 deletions include/linux/mempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,16 @@ mempool_create_slab_pool(int min_nr, struct kmem_cache *kc)
}

/*
* 2 mempool_alloc_t's and a mempool_free_t to kmalloc/kzalloc and kfree
* the amount of memory specified by pool_data
* a mempool_alloc_t and a mempool_free_t to kmalloc and kfree the
* amount of memory specified by pool_data
*/
void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data);
void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data);
void mempool_kfree(void *element, void *pool_data);
static inline mempool_t *mempool_create_kmalloc_pool(int min_nr, size_t size)
{
return mempool_create(min_nr, mempool_kmalloc, mempool_kfree,
(void *) size);
}
static inline mempool_t *mempool_create_kzalloc_pool(int min_nr, size_t size)
{
return mempool_create(min_nr, mempool_kzalloc, mempool_kfree,
(void *) size);
}

/*
* A mempool_alloc_t and mempool_free_t for a simple page allocator that
Expand Down
7 changes: 0 additions & 7 deletions mm/mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,6 @@ void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data)
}
EXPORT_SYMBOL(mempool_kmalloc);

void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data)
{
size_t size = (size_t)pool_data;
return kzalloc(size, gfp_mask);
}
EXPORT_SYMBOL(mempool_kzalloc);

void mempool_kfree(void *element, void *pool_data)
{
kfree(element);
Expand Down

0 comments on commit bba7881

Please sign in to comment.