[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0805212124250.22291@sbz-30.cs.Helsinki.FI>
Date: Wed, 21 May 2008 21:25:26 +0300 (EEST)
From: Pekka J Enberg <penberg@...helsinki.fi>
To: linux-kernel@...r.kernel.org
cc: clameter@....com, mpm@...enic.com, lethal@...ux-sh.org,
dhowells@...hat.com
Subject: [RFC/PATCH 1/3] SLAB: Add PageSlab checking to ksize()
From: Pekka Enberg <penberg@...helsinki.fi>
The ksize() function is meant for objects allocated from the slab caches, not
for arbitrary objects. Add a BUG_ON() to enforce that.
Cc: Christoph Lameter <clameter@....com>
Cc: Matt Mackall <mpm@...enic.com>
Cc: Paul Mundt <lethal@...ux-sh.org>
Cc: David Howells <dhowells@...hat.com>
Signed-off-by: Pekka Enberg <penberg@...helsinki.fi>
---
mm/slab.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index 06236e4..b98bb7c 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4472,10 +4472,14 @@ const struct seq_operations slabstats_op = {
*/
size_t ksize(const void *objp)
{
+ struct page *page;
+
BUG_ON(!objp);
if (unlikely(objp == ZERO_SIZE_PTR))
return 0;
- return obj_size(virt_to_cache(objp));
+ page = virt_to_page(objp);
+ BUG_ON(!PageSlab(page));
+ return obj_size(page_get_cache(page));
}
EXPORT_SYMBOL(ksize);
--
1.5.2.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists