Skip to content

Commit 481c534

Browse files
Christoph Lametertorvalds
authored andcommitted
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 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 62a8efe commit 481c534

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mm/slab.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3263,9 +3263,12 @@ static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
32633263

32643264
if (cpuset_zone_allowed_hardwall(zone, flags) &&
32653265
cache->nodelists[nid] &&
3266-
cache->nodelists[nid]->free_objects)
3266+
cache->nodelists[nid]->free_objects) {
32673267
obj = ____cache_alloc_node(cache,
32683268
flags | GFP_THISNODE, nid);
3269+
if (obj)
3270+
break;
3271+
}
32693272
}
32703273

32713274
if (!obj) {

0 commit comments

Comments
 (0)