brk: revert the MSP340 change to brk()
authorAlan Cox <alan@linux.intel.com>
Mon, 19 Oct 2015 20:48:41 +0000 (21:48 +0100)
committerAlan Cox <alan@linux.intel.com>
Mon, 19 Oct 2015 20:48:41 +0000 (21:48 +0100)
brk sets the memory address to the one asked. If you misalign in then it's
your problem in userspace.

Some of our sbrk() users in userspace may well be wrong, but they need to be
fixed not brk()!

Kernel/syscall_proc.c

index a48016c..e56081e 100644 (file)
@@ -225,17 +225,16 @@ arg_t _brk(void)
           need to make this something like  if (brk_valid(addr)) so we
           can keep it portable */
 
-       uaddr_t aligned = (uaddr_t) ALIGNUP(addr);
-       if (aligned >= brk_limit()) {
+       if (addr >= brk_limit()) {
                kprintf("%d: out of memory\n", udata.u_ptab->p_pid);
                udata.u_error = ENOMEM;
                return -1;
        }
        /* If we have done a break that gives us more room we must zero
           the extra as we no longer guarantee it is clear already */
-       if (aligned > udata.u_break)
-               uzero((void *)udata.u_break, aligned - udata.u_break);
-       udata.u_break = aligned;
+       if (addr > udata.u_break)
+               uzero((void *)udata.u_break, addr - udata.u_break);
+       udata.u_break = addr;
        return 0;
 }