summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2000-07-04 10:34:37 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2000-07-04 10:34:37 +0000
commita9f7725c2b75dac91b92ed1da3a3199224962261 (patch)
tree7a69ed5ae53794338d9bdfc1cf7136c6c7f0b090 /sys
parent7c165f3eb9364d2a31104ff6fcd445606a275e5f (diff)
Fix the latest fix.
Only change vm_dsize if the allocation succeeded. From Jason Thorpe.
Diffstat (limited to 'sys')
-rw-r--r--sys/uvm/uvm_unix.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/uvm/uvm_unix.c b/sys/uvm/uvm_unix.c
index 6cc5d3ae25a..c2495e917e5 100644
--- a/sys/uvm/uvm_unix.c
+++ b/sys/uvm/uvm_unix.c
@@ -83,7 +83,7 @@ sys_obreak(p, v, retval)
old = (vaddr_t)vm->vm_daddr;
new = round_page(SCARG(uap, nsize));
- if ((rlim_t)(new - old) > p->p_rlimit[RLIMIT_DATA].rlim_cur)
+ if ((new - old) > p->p_rlimit[RLIMIT_DATA].rlim_cur)
return(ENOMEM);
old = round_page(old + ptoa(vm->vm_dsize));
@@ -99,20 +99,23 @@ sys_obreak(p, v, retval)
rv = uvm_map(&vm->vm_map, &old, diff, NULL, UVM_UNKNOWN_OFFSET,
UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_COPY,
UVM_ADV_NORMAL, UVM_FLAG_AMAPPAD|UVM_FLAG_FIXED|
- UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW));
+ UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW));
+ if (rv == KERN_SUCCESS) {
+ vm->vm_dsize += atop(diff);
+ return (0);
+ }
} else {
rv = uvm_deallocate(&vm->vm_map, new, -diff);
+ if (rv == KERN_SUCCESS) {
+ vm->vm_dsize -= atop(-diff);
+ return (0);
+ }
}
- vm->vm_dsize += atop(diff);
-
- if (rv != KERN_SUCCESS) {
- uprintf("sbrk: %s failed, return = %d\n",
- diff > 0 ? "grow" : "shrink", rv);
- return(ENOMEM);
- }
-
- return (0);
+ uprintf("sbrk: %s %ld failed, return = %d\n",
+ diff > 0 ? "grow" : "shrink",
+ (long)(diff > 0 ? diff : -diff), rv);
+ return(ENOMEM);
}
/*