Skip to content

Commit

Permalink
slab, kmemleak: pass the correct pointer to kmemleak_erase()
Browse files Browse the repository at this point in the history
In ____cache_alloc(), the variable 'ac' may be changed after
cache_alloc_refill() and the following kmemleak_erase() may get an incorrect
pointer. Update 'ac' after cache_alloc_refill() unconditionally.

See the following URL for the discussion of this patch:

 http://marc.info/?l=linux-kernel&m=125873373124187&w=2

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: J. R. Okajima <hooanon05@yahoo.co.jp>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
  • Loading branch information
J. R. Okajima authored and Pekka Enberg committed Dec 6, 2009
1 parent f3d8b53 commit ddbf2e8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -3103,6 +3103,11 @@ 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
Expand Down

0 comments on commit ddbf2e8

Please sign in to comment.