OSDN Git Service

Merge branches 'slab/fixes', 'slab/kmemleak', 'slub/perf' and 'slub/stats' into for...
[armadillo-ux/linux-2.6-armadillo.git] / mm / slab.c
index a07540e..a6c9166 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3117,13 +3117,19 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
        } else {
                STATS_INC_ALLOCMISS(cachep);
                objp = cache_alloc_refill(cachep, flags);
+               /*
+                * the 'ac' may be updated by cache_alloc_refill(),
+                * and kmemleak_erase() requires its correct value.
+                */
+               ac = cpu_cache_get(cachep);
        }
        /*
         * To avoid a false negative, if an object that is in one of the
         * per-CPU caches is leaked, we need to make sure kmemleak doesn't
         * treat the array pointers as a reference to the object.
         */
-       kmemleak_erase(&ac->entry[ac->avail]);
+       if (objp)
+               kmemleak_erase(&ac->entry[ac->avail]);
        return objp;
 }