Skip to content

Commit

Permalink
slab: fix for_each_kmem_cache_node()
Browse files Browse the repository at this point in the history
Fix a bug (discovered with kmemcheck) in for_each_kmem_cache_node().  The
for loop reads the array "node" before verifying that the index is within
the range.  This results in kmemcheck warning.

Signed-off-by: Mikulas Patocka <[email protected]>
Reviewed-by: Pekka Enberg <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Mikulas Patocka authored and torvalds committed Oct 10, 2014
1 parent 1092283 commit 9163582
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node)
* a kmem_cache_node structure allocated (which is true for all online nodes)
*/
#define for_each_kmem_cache_node(__s, __node, __n) \
for (__node = 0; __n = get_node(__s, __node), __node < nr_node_ids; __node++) \
if (__n)
for (__node = 0; __node < nr_node_ids; __node++) \
if ((__n = get_node(__s, __node)))

#endif

Expand Down

0 comments on commit 9163582

Please sign in to comment.