Prepare to handle non-trivial errors from vm_map_delete().
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24652
This commit is contained in:
parent
4ebfc4edaf
commit
e8f77c204b
@ -1868,8 +1868,11 @@ vm_map_fixed(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
|
||||
("vm_map_fixed: non-NULL backing object for stack"));
|
||||
vm_map_lock(map);
|
||||
VM_MAP_RANGE_CHECK(map, start, end);
|
||||
if ((cow & MAP_CHECK_EXCL) == 0)
|
||||
vm_map_delete(map, start, end);
|
||||
if ((cow & MAP_CHECK_EXCL) == 0) {
|
||||
result = vm_map_delete(map, start, end);
|
||||
if (result != KERN_SUCCESS)
|
||||
goto out;
|
||||
}
|
||||
if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) {
|
||||
result = vm_map_stack_locked(map, start, length, sgrowsiz,
|
||||
prot, max, cow);
|
||||
@ -1877,6 +1880,7 @@ vm_map_fixed(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
|
||||
result = vm_map_insert(map, object, offset, start, end,
|
||||
prot, max, cow);
|
||||
}
|
||||
out:
|
||||
vm_map_unlock(map);
|
||||
return (result);
|
||||
}
|
||||
@ -2115,7 +2119,9 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset,
|
||||
rv = KERN_INVALID_ADDRESS;
|
||||
goto done;
|
||||
}
|
||||
vm_map_delete(map, *addr, *addr + length);
|
||||
rv = vm_map_delete(map, *addr, *addr + length);
|
||||
if (rv != KERN_SUCCESS)
|
||||
goto done;
|
||||
}
|
||||
if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) {
|
||||
rv = vm_map_stack_locked(map, *addr, length, sgrowsiz, prot,
|
||||
|
@ -577,6 +577,7 @@ kern_munmap(struct thread *td, uintptr_t addr0, size_t size)
|
||||
vm_offset_t addr, end;
|
||||
vm_size_t pageoff;
|
||||
vm_map_t map;
|
||||
int rv;
|
||||
|
||||
if (size == 0)
|
||||
return (EINVAL);
|
||||
@ -614,10 +615,10 @@ kern_munmap(struct thread *td, uintptr_t addr0, size_t size)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
vm_map_delete(map, addr, end);
|
||||
rv = vm_map_delete(map, addr, end);
|
||||
|
||||
#ifdef HWPMC_HOOKS
|
||||
if (__predict_false(pmc_handled)) {
|
||||
if (rv == KERN_SUCCESS && __predict_false(pmc_handled)) {
|
||||
/* downgrade the lock to prevent a LOR with the pmc-sx lock */
|
||||
vm_map_lock_downgrade(map);
|
||||
if (pkm.pm_address != (uintptr_t) NULL)
|
||||
@ -627,8 +628,7 @@ kern_munmap(struct thread *td, uintptr_t addr0, size_t size)
|
||||
#endif
|
||||
vm_map_unlock(map);
|
||||
|
||||
/* vm_map_delete returns nothing but KERN_SUCCESS anyway */
|
||||
return (0);
|
||||
return (vm_mmap_to_errno(rv));
|
||||
}
|
||||
|
||||
#ifndef _SYS_SYSPROTO_H_
|
||||
|
@ -188,7 +188,7 @@ kern_break(struct thread *td, uintptr_t *addr)
|
||||
rv = vm_map_wire_locked(map, old, new,
|
||||
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
|
||||
if (rv != KERN_SUCCESS)
|
||||
vm_map_delete(map, old, new);
|
||||
(void)vm_map_delete(map, old, new);
|
||||
}
|
||||
if (rv != KERN_SUCCESS) {
|
||||
#ifdef RACCT
|
||||
|
Loading…
Reference in New Issue
Block a user