Re: [RFC v3 2/5] slab: implement slab object boundaries assertion

From: Christoph Lameter
Date: Thu Jul 21 2011 - 12:28:15 EST


On Thu, 21 Jul 2011, Vasiliy Kulikov wrote:

> +bool slab_access_ok(const void *ptr, unsigned long len)
> +{
> + struct page *page;
> + struct kmem_cache *s = NULL;

Useless assignment.

> + unsigned long offset;
> +
> + if (!virt_addr_valid(ptr))
> + return true;
> + page = virt_to_head_page(ptr);
> + if (!PageSlab(page))
> + return true;
> +
> + s = page->slab;
> + offset = (ptr - page_address(page)) % s->size;
> + if (offset <= s->objsize && len <= s->objsize - offset)
> + return true;

I thought this was going to be offset < s->objectsize ...?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/