SLUB: use check_valid_pointer in kmem_ptr_validate

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>
This commit is contained in:
Christoph Lameter 2007-05-09 02:32:37 -07:00 committed by Linus Torvalds
parent a87615b8f9
commit abcd08a6f5
1 changed files with 3 additions and 10 deletions

View File

@ -405,9 +405,8 @@ static int check_bytes(u8 *start, unsigned int value, unsigned int bytes)
return 1; return 1;
} }
static inline int check_valid_pointer(struct kmem_cache *s,
static int check_valid_pointer(struct kmem_cache *s, struct page *page, struct page *page, const void *object)
void *object)
{ {
void *base; void *base;
@ -1796,13 +1795,7 @@ int kmem_ptr_validate(struct kmem_cache *s, const void *object)
/* No slab or wrong slab */ /* No slab or wrong slab */
return 0; return 0;
addr = page_address(page); if (!check_valid_pointer(s, page, object))
if (object < addr || object >= addr + s->objects * s->size)
/* Out of bounds */
return 0;
if ((object - addr) % s->size)
/* Improperly aligned */
return 0; return 0;
/* /*