From: Mikulas Patocka Date: Thu, 9 Oct 2014 22:26:20 +0000 (-0700) Subject: slab: fix for_each_kmem_cache_node() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9163582c3f22cfba90a78749751ac70b127a9167;p=openwrt%2Fstaging%2Fblogic.git slab: fix for_each_kmem_cache_node() 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 Reviewed-by: Pekka Enberg Acked-by: Christoph Lameter Cc: David Rientjes Cc: Joonsoo Kim Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/slab.h b/mm/slab.h index 026e7c393f0b..6599f2084e80 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -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