Commit 6cd576130b7152d8f225bab9d21a3f6f96c84b47
Committed by
Linus Torvalds
1 parent
12215182c8
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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>
Showing 1 changed file with 8 additions and 17 deletions Side-by-side Diff
mm/mremap.c
... | ... | @@ -345,25 +345,25 @@ |
345 | 345 | struct vm_area_struct *vma = find_vma(mm, addr); |
346 | 346 | |
347 | 347 | if (!vma || vma->vm_start > addr) |
348 | - goto Efault; | |
348 | + return ERR_PTR(-EFAULT); | |
349 | 349 | |
350 | 350 | if (is_vm_hugetlb_page(vma)) |
351 | - goto Einval; | |
351 | + return ERR_PTR(-EINVAL); | |
352 | 352 | |
353 | 353 | /* We can't remap across vm area boundaries */ |
354 | 354 | if (old_len > vma->vm_end - addr) |
355 | - goto Efault; | |
355 | + return ERR_PTR(-EFAULT); | |
356 | 356 | |
357 | 357 | /* Need to be careful about a growing mapping */ |
358 | 358 | if (new_len > old_len) { |
359 | 359 | unsigned long pgoff; |
360 | 360 | |
361 | 361 | if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP)) |
362 | - goto Efault; | |
362 | + return ERR_PTR(-EFAULT); | |
363 | 363 | pgoff = (addr - vma->vm_start) >> PAGE_SHIFT; |
364 | 364 | pgoff += vma->vm_pgoff; |
365 | 365 | if (pgoff + (new_len >> PAGE_SHIFT) < pgoff) |
366 | - goto Einval; | |
366 | + return ERR_PTR(-EINVAL); | |
367 | 367 | } |
368 | 368 | |
369 | 369 | if (vma->vm_flags & VM_LOCKED) { |
370 | 370 | |
371 | 371 | |
372 | 372 | |
... | ... | @@ -372,29 +372,20 @@ |
372 | 372 | lock_limit = rlimit(RLIMIT_MEMLOCK); |
373 | 373 | locked += new_len - old_len; |
374 | 374 | if (locked > lock_limit && !capable(CAP_IPC_LOCK)) |
375 | - goto Eagain; | |
375 | + return ERR_PTR(-EAGAIN); | |
376 | 376 | } |
377 | 377 | |
378 | 378 | if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) |
379 | - goto Enomem; | |
379 | + return ERR_PTR(-ENOMEM); | |
380 | 380 | |
381 | 381 | if (vma->vm_flags & VM_ACCOUNT) { |
382 | 382 | unsigned long charged = (new_len - old_len) >> PAGE_SHIFT; |
383 | 383 | if (security_vm_enough_memory_mm(mm, charged)) |
384 | - goto Enomem; | |
384 | + return ERR_PTR(-ENOMEM); | |
385 | 385 | *p = charged; |
386 | 386 | } |
387 | 387 | |
388 | 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 | 391 | static unsigned long mremap_to(unsigned long addr, unsigned long old_len, |