diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2020-09-09 21:34:31 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2020-09-09 21:34:31 +0000 |
| commit | e8f77c204bf0aafa5bdb7aef906d0665e6a8b843 (patch) | |
| tree | 5cd81bf92d30bf4783c71f4d6858993165bc1e1e /sys/vm | |
| parent | 4ebfc4edaf21c26b5c2693fdf7bfaec3d8abd6e0 (diff) | |
Notes
Diffstat (limited to 'sys/vm')
| -rw-r--r-- | sys/vm/vm_map.c | 12 | ||||
| -rw-r--r-- | sys/vm/vm_mmap.c | 8 | ||||
| -rw-r--r-- | sys/vm/vm_unix.c | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index dae38faf8e11..e68f7d315959 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -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 @@ again: 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, diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index e0f3da8ed704..d0c38c2e8082 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -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_ diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c index ff12c3008444..8b3fce6b49a9 100644 --- a/sys/vm/vm_unix.c +++ b/sys/vm/vm_unix.c @@ -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 |
