|
@@ -345,25 +345,25 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
|
|
struct vm_area_struct *vma = find_vma(mm, addr);
|
|
struct vm_area_struct *vma = find_vma(mm, addr);
|
|
|
|
|
|
if (!vma || vma->vm_start > addr)
|
|
if (!vma || vma->vm_start > addr)
|
|
- goto Efault;
|
|
|
|
|
|
+ return ERR_PTR(-EFAULT);
|
|
|
|
|
|
if (is_vm_hugetlb_page(vma))
|
|
if (is_vm_hugetlb_page(vma))
|
|
- goto Einval;
|
|
|
|
|
|
+ return ERR_PTR(-EINVAL);
|
|
|
|
|
|
/* We can't remap across vm area boundaries */
|
|
/* We can't remap across vm area boundaries */
|
|
if (old_len > vma->vm_end - addr)
|
|
if (old_len > vma->vm_end - addr)
|
|
- goto Efault;
|
|
|
|
|
|
+ return ERR_PTR(-EFAULT);
|
|
|
|
|
|
/* Need to be careful about a growing mapping */
|
|
/* Need to be careful about a growing mapping */
|
|
if (new_len > old_len) {
|
|
if (new_len > old_len) {
|
|
unsigned long pgoff;
|
|
unsigned long pgoff;
|
|
|
|
|
|
if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP))
|
|
if (vma->vm_flags & (VM_DONTEXPAND | VM_PFNMAP))
|
|
- goto Efault;
|
|
|
|
|
|
+ return ERR_PTR(-EFAULT);
|
|
pgoff = (addr - vma->vm_start) >> PAGE_SHIFT;
|
|
pgoff = (addr - vma->vm_start) >> PAGE_SHIFT;
|
|
pgoff += vma->vm_pgoff;
|
|
pgoff += vma->vm_pgoff;
|
|
if (pgoff + (new_len >> PAGE_SHIFT) < pgoff)
|
|
if (pgoff + (new_len >> PAGE_SHIFT) < pgoff)
|
|
- goto Einval;
|
|
|
|
|
|
+ return ERR_PTR(-EINVAL);
|
|
}
|
|
}
|
|
|
|
|
|
if (vma->vm_flags & VM_LOCKED) {
|
|
if (vma->vm_flags & VM_LOCKED) {
|
|
@@ -372,29 +372,20 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
|
|
lock_limit = rlimit(RLIMIT_MEMLOCK);
|
|
lock_limit = rlimit(RLIMIT_MEMLOCK);
|
|
locked += new_len - old_len;
|
|
locked += new_len - old_len;
|
|
if (locked > lock_limit && !capable(CAP_IPC_LOCK))
|
|
if (locked > lock_limit && !capable(CAP_IPC_LOCK))
|
|
- goto Eagain;
|
|
|
|
|
|
+ return ERR_PTR(-EAGAIN);
|
|
}
|
|
}
|
|
|
|
|
|
if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT))
|
|
if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT))
|
|
- goto Enomem;
|
|
|
|
|
|
+ return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
if (vma->vm_flags & VM_ACCOUNT) {
|
|
if (vma->vm_flags & VM_ACCOUNT) {
|
|
unsigned long charged = (new_len - old_len) >> PAGE_SHIFT;
|
|
unsigned long charged = (new_len - old_len) >> PAGE_SHIFT;
|
|
if (security_vm_enough_memory_mm(mm, charged))
|
|
if (security_vm_enough_memory_mm(mm, charged))
|
|
- goto Enomem;
|
|
|
|
|
|
+ return ERR_PTR(-ENOMEM);
|
|
*p = charged;
|
|
*p = charged;
|
|
}
|
|
}
|
|
|
|
|
|
return vma;
|
|
return vma;
|
|
-
|
|
|
|
-Efault: /* very odd choice for most of the cases, but... */
|
|
|
|
- return ERR_PTR(-EFAULT);
|
|
|
|
-Einval:
|
|
|
|
- return ERR_PTR(-EINVAL);
|
|
|
|
-Enomem:
|
|
|
|
- return ERR_PTR(-ENOMEM);
|
|
|
|
-Eagain:
|
|
|
|
- return ERR_PTR(-EAGAIN);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
|
|
static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
|