slub: Add check for kfree() of non slab objects.
authorChristoph Lameter <clameter@sgi.com>
Wed, 28 May 2008 17:32:22 +0000 (10:32 -0700)
committerPekka Enberg <penberg@cs.helsinki.fi>
Tue, 15 Jul 2008 17:36:01 +0000 (20:36 +0300)
We can detect kfree()s on non slab objects by checking for PageCompound().
Works in the same way as for ksize. This helped me catch an invalid
kfree().

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
mm/slub.c

index 5f6e2c4a2ba7cbf51e85961eaa56b9d3f82981f0..b3f2e713cdf13d0b17509ed83eadf1117d107637 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2766,6 +2766,7 @@ void kfree(const void *x)
 
        page = virt_to_head_page(x);
        if (unlikely(!PageSlab(page))) {
+               BUG_ON(!PageCompound(page));
                put_page(page);
                return;
        }