diff options
author | Glauber Costa <glommer@parallels.com> | 2012-12-18 17:22:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-18 18:02:14 -0500 |
commit | b9ce5ef49f00daf2254c6953c8d31f79aabccd34 (patch) | |
tree | 1da6afdbb3dc2e2d31f588dbfbf502e984af48a6 /mm/slub.c | |
parent | 0e9d92f2d02d8c8320f0502307c688d07bdac2b3 (diff) |
sl[au]b: always get the cache from its page in kmem_cache_free()
struct page already has this information. If we start chaining caches,
this information will always be more trustworthy than whatever is passed
into the function.
Signed-off-by: Glauber Costa <glommer@parallels.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Frederic Weisbecker <fweisbec@redhat.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: JoonSoo Kim <js1304@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Rik van Riel <riel@redhat.com>
Cc: Suleiman Souhlal <suleiman@google.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 15 |
1 files changed, 3 insertions, 12 deletions
@@ -2611,19 +2611,10 @@ redo: | |||
2611 | 2611 | ||
2612 | void kmem_cache_free(struct kmem_cache *s, void *x) | 2612 | void kmem_cache_free(struct kmem_cache *s, void *x) |
2613 | { | 2613 | { |
2614 | struct page *page; | 2614 | s = cache_from_obj(s, x); |
2615 | 2615 | if (!s) | |
2616 | page = virt_to_head_page(x); | ||
2617 | |||
2618 | if (kmem_cache_debug(s) && page->slab_cache != s) { | ||
2619 | pr_err("kmem_cache_free: Wrong slab cache. %s but object" | ||
2620 | " is from %s\n", page->slab_cache->name, s->name); | ||
2621 | WARN_ON_ONCE(1); | ||
2622 | return; | 2616 | return; |
2623 | } | 2617 | slab_free(s, virt_to_head_page(x), x, _RET_IP_); |
2624 | |||
2625 | slab_free(s, page, x, _RET_IP_); | ||
2626 | |||
2627 | trace_kmem_cache_free(_RET_IP_, x); | 2618 | trace_kmem_cache_free(_RET_IP_, x); |
2628 | } | 2619 | } |
2629 | EXPORT_SYMBOL(kmem_cache_free); | 2620 | EXPORT_SYMBOL(kmem_cache_free); |