aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-27 18:57:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-27 18:57:31 -0400
commit5d22fc25d4fc8096d2d7df27ea1893d4e055e764 (patch)
tree464a86dc3d004dd334e37a8fe7e7b42f8511581e /fs
parent287980e49ffc0f6d911601e7e352a812ed27768e (diff)
mm: remove more IS_ERR_VALUE abuses
The do_brk() and vm_brk() return value was "unsigned long" and returned the starting address on success, and an error value on failure. The reasons are entirely historical, and go back to it basically behaving like the mmap() interface does. However, nobody actually wanted that interface, and it causes totally pointless IS_ERR_VALUE() confusion. What every single caller actually wants is just the simpler integer return of zero for success and negative error number on failure. So just convert to that much clearer and more common calling convention, and get rid of all the IS_ERR_VALUE() uses wrt vm_brk(). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/binfmt_aout.c18
-rw-r--r--fs/binfmt_elf.c11
2 files changed, 12 insertions, 17 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 2fab9f130e51..64b331ae3428 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -127,11 +127,8 @@ static int set_brk(unsigned long start, unsigned long end)
127{ 127{
128 start = PAGE_ALIGN(start); 128 start = PAGE_ALIGN(start);
129 end = PAGE_ALIGN(end); 129 end = PAGE_ALIGN(end);
130 if (end > start) { 130 if (end > start)
131 unsigned long addr; 131 return vm_brk(start, end - start);
132 addr = vm_brk(start, end - start);
133 if (BAD_ADDR(addr))
134 return addr;
135 } 132 }
136 return 0; 133 return 0;
137} 134}
@@ -275,7 +272,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
275 map_size = ex.a_text+ex.a_data; 272 map_size = ex.a_text+ex.a_data;
276#endif 273#endif
277 error = vm_brk(text_addr & PAGE_MASK, map_size); 274 error = vm_brk(text_addr & PAGE_MASK, map_size);
278 if (error != (text_addr & PAGE_MASK)) 275 if (error)
279 return error; 276 return error;
280 277
281 error = read_code(bprm->file, text_addr, pos, 278 error = read_code(bprm->file, text_addr, pos,
@@ -298,7 +295,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
298 295
299 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) { 296 if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) {
300 error = vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); 297 error = vm_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
301 if (IS_ERR_VALUE(error)) 298 if (error)
302 return error; 299 return error;
303 300
304 read_code(bprm->file, N_TXTADDR(ex), fd_offset, 301 read_code(bprm->file, N_TXTADDR(ex), fd_offset,
@@ -382,7 +379,7 @@ static int load_aout_library(struct file *file)
382 file); 379 file);
383 } 380 }
384 retval = vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); 381 retval = vm_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
385 if (IS_ERR_VALUE(retval)) 382 if (retval)
386 goto out; 383 goto out;
387 384
388 read_code(file, start_addr, N_TXTOFF(ex), 385 read_code(file, start_addr, N_TXTOFF(ex),
@@ -402,9 +399,8 @@ static int load_aout_library(struct file *file)
402 len = PAGE_ALIGN(ex.a_text + ex.a_data); 399 len = PAGE_ALIGN(ex.a_text + ex.a_data);
403 bss = ex.a_text + ex.a_data + ex.a_bss; 400 bss = ex.a_text + ex.a_data + ex.a_bss;
404 if (bss > len) { 401 if (bss > len) {
405 error = vm_brk(start_addr + len, bss - len); 402 retval = vm_brk(start_addr + len, bss - len);
406 retval = error; 403 if (retval)
407 if (error != start_addr + len)
408 goto out; 404 goto out;
409 } 405 }
410 retval = 0; 406 retval = 0;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 938fc4ede764..e158b22ef32f 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -96,10 +96,9 @@ static int set_brk(unsigned long start, unsigned long end)
96 start = ELF_PAGEALIGN(start); 96 start = ELF_PAGEALIGN(start);
97 end = ELF_PAGEALIGN(end); 97 end = ELF_PAGEALIGN(end);
98 if (end > start) { 98 if (end > start) {
99 unsigned long addr; 99 int error = vm_brk(start, end - start);
100 addr = vm_brk(start, end - start); 100 if (error)
101 if (BAD_ADDR(addr)) 101 return error;
102 return addr;
103 } 102 }
104 current->mm->start_brk = current->mm->brk = end; 103 current->mm->start_brk = current->mm->brk = end;
105 return 0; 104 return 0;
@@ -629,7 +628,7 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
629 628
630 /* Map the last of the bss segment */ 629 /* Map the last of the bss segment */
631 error = vm_brk(elf_bss, last_bss - elf_bss); 630 error = vm_brk(elf_bss, last_bss - elf_bss);
632 if (BAD_ADDR(error)) 631 if (error)
633 goto out; 632 goto out;
634 } 633 }
635 634
@@ -1178,7 +1177,7 @@ static int load_elf_library(struct file *file)
1178 bss = eppnt->p_memsz + eppnt->p_vaddr; 1177 bss = eppnt->p_memsz + eppnt->p_vaddr;
1179 if (bss > len) { 1178 if (bss > len) {
1180 error = vm_brk(len, bss - len); 1179 error = vm_brk(len, bss - len);
1181 if (BAD_ADDR(error)) 1180 if (error)
1182 goto out_free_ph; 1181 goto out_free_ph;
1183 } 1182 }
1184 error = 0; 1183 error = 0;