Skip to content

Commit

Permalink
SLUB: use check_valid_pointer in kmem_ptr_validate
Browse files Browse the repository at this point in the history
We needlessly duplicate code. Also make check_valid_pointer inline.

Signed-off-by: Christoph LAemter <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 9, 2007
1 parent a87615b commit abcd08a
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,8 @@ static int check_bytes(u8 *start, unsigned int value, unsigned int bytes)
return 1;
}


static int check_valid_pointer(struct kmem_cache *s, struct page *page,
void *object)
static inline int check_valid_pointer(struct kmem_cache *s,
struct page *page, const void *object)
{
void *base;

Expand Down Expand Up @@ -1796,13 +1795,7 @@ int kmem_ptr_validate(struct kmem_cache *s, const void *object)
/* No slab or wrong slab */
return 0;

addr = page_address(page);
if (object < addr || object >= addr + s->objects * s->size)
/* Out of bounds */
return 0;

if ((object - addr) % s->size)
/* Improperly aligned */
if (!check_valid_pointer(s, page, object))
return 0;

/*
Expand Down

0 comments on commit abcd08a

Please sign in to comment.