提交 abcd08a6 编写于 作者: C Christoph Lameter 提交者: Linus Torvalds

SLUB: use check_valid_pointer in kmem_ptr_validate

We needlessly duplicate code. Also make check_valid_pointer inline.
Signed-off-by: NChristoph LAemter <clameter@sgi.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 a87615b8
......@@ -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;
......@@ -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;
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册