Skip to content

Commit

Permalink
slab: warn on zero-length allocations
Browse files Browse the repository at this point in the history
slub warns on this, and we're working on making kmalloc(0) return NULL.
Let's make slab warn as well so our testers detect such callers more
rapidly.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed May 17, 2007
1 parent 4b6f075 commit 0b44f7a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
*/
BUG_ON(malloc_sizes[INDEX_AC].cs_cachep == NULL);
#endif
WARN_ON_ONCE(size == 0);
while (size > csizep->cs_size)
csizep++;

Expand Down

0 comments on commit 0b44f7a

Please sign in to comment.