diff options
author | Derek <denc716@gmail.com> | 2015-04-15 19:14:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:18 -0400 |
commit | 6cd576130b7152d8f225bab9d21a3f6f96c84b47 (patch) | |
tree | 4c3f0e4977cd5d871dd93de6d55f0ff502db8ef2 /mm/mremap.c | |
parent | 12215182c80c06ab3c69969abba6e4a834493cd8 (diff) |
mm/mremap.c: clean up goto just return ERR_PTR
As suggested by Kirill the "goto"s in vma_to_resize aren't necessary, just
change them to explicit return.
Signed-off-by: Derek Che <crquan@ymail.com>
Suggested-by: "Kirill A. Shutemov" <kirill@shutemov.name>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mremap.c')
-rw-r--r-- | mm/mremap.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/mm/mremap.c b/mm/mremap.c index 1fb0f9069653..034e2d360652 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -345,25 +345,25 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr, | |||
345 | struct vm_area_struct *vma = find_vma(mm, addr); | 345 | struct vm_area_struct *vma = find_vma(mm, addr); |
346 | 346 | ||
347 | if (!vma || vma->vm_start > addr) | 347 | if (!vma || vma->vm_start > addr) |
348 | goto Efault; | 348 | return ERR_PTR(-EFAULT); |
349 | 349 | ||
350 | if (is_vm_hugetlb_page(vma)) | 350 | if (is_vm_hugetlb_page(vma)) |
351 | goto Einval; | 351 | return ERR_PTR(-EINVAL); |
352 | 352 | ||
353 | /* We can't remap across vm area boundaries */ | 353 | /* We can't remap across vm area boundaries */ |
354 | if (old_len > vma->vm_end - addr) | 354 | if (old_len > vma->vm_end - addr) |
355 | goto Efault; | 355 | return ERR_PTR(-EFAULT); |
356 | 356 | ||
357 | /* Need to be careful about a growing mapping */ | 357 | /* Need to be careful about a growing mapping */ |
358 | if (new_len > old_len) { | 358 | if (new_len > old_len) { |
359 | unsigned long pgoff; | 359 | unsigned long pgoff; |
360 | 360 | ||
361 | if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP)) | 361 | if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP)) |
362 | goto Efault; | 362 | return ERR_PTR(-EFAULT); |
363 | pgoff = (addr - vma->vm_start) >> PAGE_SHIFT; | 363 | pgoff = (addr - vma->vm_start) >> PAGE_SHIFT; |
364 | pgoff += vma->vm_pgoff; | 364 | pgoff += vma->vm_pgoff; |
365 | if (pgoff + (new_len >> PAGE_SHIFT) < pgoff) | 365 | if (pgoff + (new_len >> PAGE_SHIFT) < pgoff) |
366 | goto Einval; | 366 | return ERR_PTR(-EINVAL); |
367 | } | 367 | } |
368 | 368 | ||
369 | if (vma->vm_flags & VM_LOCKED) { | 369 | if (vma->vm_flags & VM_LOCKED) { |
@@ -372,29 +372,20 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr, | |||
372 | lock_limit = rlimit(RLIMIT_MEMLOCK); | 372 | lock_limit = rlimit(RLIMIT_MEMLOCK); |
373 | locked += new_len - old_len; | 373 | locked += new_len - old_len; |
374 | if (locked > lock_limit && !capable(CAP_IPC_LOCK)) | 374 | if (locked > lock_limit && !capable(CAP_IPC_LOCK)) |
375 | goto Eagain; | 375 | return ERR_PTR(-EAGAIN); |
376 | } | 376 | } |
377 | 377 | ||
378 | if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) | 378 | if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) |
379 | goto Enomem; | 379 | return ERR_PTR(-ENOMEM); |
380 | 380 | ||
381 | if (vma->vm_flags & VM_ACCOUNT) { | 381 | if (vma->vm_flags & VM_ACCOUNT) { |
382 | unsigned long charged = (new_len - old_len) >> PAGE_SHIFT; | 382 | unsigned long charged = (new_len - old_len) >> PAGE_SHIFT; |
383 | if (security_vm_enough_memory_mm(mm, charged)) | 383 | if (security_vm_enough_memory_mm(mm, charged)) |
384 | goto Enomem; | 384 | return ERR_PTR(-ENOMEM); |
385 | *p = charged; | 385 | *p = charged; |
386 | } | 386 | } |
387 | 387 | ||
388 | return vma; | 388 | return vma; |
389 | |||
390 | Efault: /* very odd choice for most of the cases, but... */ | ||
391 | return ERR_PTR(-EFAULT); | ||
392 | Einval: | ||
393 | return ERR_PTR(-EINVAL); | ||
394 | Enomem: | ||
395 | return ERR_PTR(-ENOMEM); | ||
396 | Eagain: | ||
397 | return ERR_PTR(-EAGAIN); | ||
398 | } | 389 | } |
399 | 390 | ||
400 | static unsigned long mremap_to(unsigned long addr, unsigned long old_len, | 391 | static unsigned long mremap_to(unsigned long addr, unsigned long old_len, |