Skip to content

Commit

Permalink
slub: Remove BUG_ON() from ksize and omit checks for !SLUB_DEBUG
Browse files Browse the repository at this point in the history
The BUG_ONs are useless since the pointer derefs will lead to
NULL deref errors anyways. Some of the checks are not necessary
if no debugging is possible.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
  • Loading branch information
Christoph Lameter committed Mar 3, 2008
1 parent 27d9e4e commit ae20bfd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2610,34 +2610,32 @@ size_t ksize(const void *object)
struct page *page;
struct kmem_cache *s;

BUG_ON(!object);
if (unlikely(object == ZERO_SIZE_PTR))
return 0;

page = virt_to_head_page(object);
BUG_ON(!page);

if (unlikely(!PageSlab(page)))
return PAGE_SIZE << compound_order(page);

s = page->slab;
BUG_ON(!s);

#ifdef CONFIG_SLUB_DEBUG
/*
* Debugging requires use of the padding between object
* and whatever may come after it.
*/
if (s->flags & (SLAB_RED_ZONE | SLAB_POISON))
return s->objsize;

#endif
/*
* If we have the need to store the freelist pointer
* back there or track user information then we can
* only use the space before that information.
*/
if (s->flags & (SLAB_DESTROY_BY_RCU | SLAB_STORE_USER))
return s->inuse;

/*
* Else we can use all the padding etc for the allocation
*/
Expand Down

0 comments on commit ae20bfd

Please sign in to comment.