Re: [PATCH] nommu: fix kobjsize() for SLOB and SLUB, v2.

From: Christoph Lameter
Date: Tue Jun 10 2008 - 13:30:52 EST


On Mon, 2 Jun 2008, Paul Mundt wrote:

> + page = virt_to_head_page(objp);
> + if (!page)
> + return 0;

virt_to_head_page cannot return NULL. virt_to_page also does not return
NULL. pfn_valid() needs to be used to figure out if a page is valid.
Otherwise the page struct reference that was returned may have
PageReserved() set to indicate that it is not a valid page.

> + * The ksize() function is only guaranteed to work for pointers
> + * returned by kmalloc(). So handle arbitrary pointers, that we expect
> + * always to be compound pages, here.
> + */
> + if (PageCompound(page))
> + order = compound_order(page);

compund order returns 0 if you use compound_order() on a
non compound page. No need for the PageCompound test.

--
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/