Messages in this thread | | | Date | Thu, 7 Jul 2011 13:48:51 -0500 (CDT) | From | Christoph Lameter <> | Subject | Re: [PATCH v3 2/2] slub: Add method to verify memory is not freed. |
| |
On Thu, 7 Jul 2011, greearb@candelatech.com wrote:
> + struct page *page; > + void *object = (void *)x; > + unsigned long flags; > + bool rv; > + > + if (unlikely(ZERO_OR_NULL_PTR(x))) > + return false; > + > + local_irq_save(flags); > + > + page = virt_to_head_page(x); > + if (unlikely(!PageSlab(page))) { > + /* maybe it was from stack? */
Or it is a compound page that was used because the allocation was larger than an order 2 alloc. Same result though.
> + rv = true; > + goto out_unlock; > + } > + > + slab_lock(page); > + if (on_freelist(page->slab, page, object)) { > + object_err(page->slab, page, object, "Object is on free-list"); > + rv = false; > + } else { > + rv = true; > + } > + slab_unlock(page); > + > +out_unlock: > + local_irq_restore(flags); > + return rv; > +} > +EXPORT_SYMBOL(verify_mem_not_deleted); > +#endif > + > void kfree(const void *x) > { > struct page *page; >
Acked-by: Christoph Lameter <cl@linux.com>
| |