X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=mm%2Fnommu.c;h=4462b6a3fcb984e9bd37a69ef7d377f0b5dd2367;hb=4422b00390749f8b877b2838a99ef2948ae08a58;hp=dca93fcb8b7a6517ad041221343bddf61e572644;hpb=80119ef5c8153e0a6cc5edf00c083dc98a9bd348;p=linux-2.6-omap-h63xx.git diff --git a/mm/nommu.c b/mm/nommu.c index dca93fcb8b7..4462b6a3fcb 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -109,16 +109,23 @@ unsigned int kobjsize(const void *objp) * If the object we have should not have ksize performed on it, * return size of 0 */ - if (!objp || (unsigned long)objp >= memory_end || !((page = virt_to_page(objp)))) + if (!objp || !virt_addr_valid(objp)) return 0; + page = virt_to_head_page(objp); + + /* + * If the allocator sets PageSlab, we know the pointer came from + * kmalloc(). + */ if (PageSlab(page)) return ksize(objp); - BUG_ON(page->index < 0); - BUG_ON(page->index >= MAX_ORDER); - - return (PAGE_SIZE << page->index); + /* + * The ksize() function is only guaranteed to work for pointers + * returned by kmalloc(). So handle arbitrary pointers here. + */ + return PAGE_SIZE << compound_order(page); } /*