Hi, I was updating this patch and I've gut a doubt with what to do with the result of vm_map_find_entry_anywhere in case of a failure to enforce the limit.
I end up with code like below: if (anywhere) { entry = vm_map_find_entry_anywhere(map, size, mask, FALSE, &start); if (entry == NULL) { RETURN(KERN_NO_SPACE); } end = start + size; *address = start; next_entry = entry->vme_next; } else { ... vm_map_lock(map); ... } followed by the call to vm_map_enforce_limit: /* * If the allocation has protection equal to VM_PROT_NONE, * don't check for limits as the map's size_none field is * not yet incremented. */ if (max_protection != VM_PROT_NONE) { if ((result = vm_map_enforce_limit(map, size, "vm_map_enter")) != KERN_SUCCESS) RETURN(result); } it requires the map locked which is the case as if anywhere is TRUE vm_map_find_entry_anywhere call will lock the map and otherwise the map is locked in the else case of the if in the first snippet. My doubt is what to do the non NULL entry in case result, returned by the enforcer function, is not KERN_SUCCESS. Wouldn't I be leaking a vm_map_entry_t? Diego