瀏覽代碼

Slab: Fix memory leak in fallback_alloc()

The zonelist patches caused the loop that checks for available
objects in permitted zones to not terminate immediately. One object
per zone per allocation may be allocated and then abandoned.

Break the loop when we have successfully allocated one object.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Christoph Lameter 17 年之前
父節點
當前提交
481c5346d0
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      mm/slab.c

+ 4 - 1
mm/slab.c

@@ -3263,9 +3263,12 @@ retry:
 
 
 		if (cpuset_zone_allowed_hardwall(zone, flags) &&
 		if (cpuset_zone_allowed_hardwall(zone, flags) &&
 			cache->nodelists[nid] &&
 			cache->nodelists[nid] &&
-			cache->nodelists[nid]->free_objects)
+			cache->nodelists[nid]->free_objects) {
 				obj = ____cache_alloc_node(cache,
 				obj = ____cache_alloc_node(cache,
 					flags | GFP_THISNODE, nid);
 					flags | GFP_THISNODE, nid);
+				if (obj)
+					break;
+		}
 	}
 	}
 
 
 	if (!obj) {
 	if (!obj) {