Commit de1741a1 authored by Alexander Kuleshov's avatar Alexander Kuleshov Committed by Linus Torvalds

mm/mmap: use offset_in_page macro

linux/mm.h provides offset_in_page() macro.  Let's use already predefined
macro instead of (addr & ~PAGE_MASK).
Signed-off-by: default avatarAlexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 891c49ab
...@@ -1302,7 +1302,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr, ...@@ -1302,7 +1302,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
* that it represents a valid section of the address space. * that it represents a valid section of the address space.
*/ */
addr = get_unmapped_area(file, addr, len, pgoff, flags); addr = get_unmapped_area(file, addr, len, pgoff, flags);
if (addr & ~PAGE_MASK) if (offset_in_page(addr))
return addr; return addr;
/* Do simple checking here so the lower-level routines won't have /* Do simple checking here so the lower-level routines won't have
...@@ -1473,7 +1473,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg) ...@@ -1473,7 +1473,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg)
if (copy_from_user(&a, arg, sizeof(a))) if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT; return -EFAULT;
if (a.offset & ~PAGE_MASK) if (offset_in_page(a.offset))
return -EINVAL; return -EINVAL;
return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
...@@ -1989,7 +1989,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, ...@@ -1989,7 +1989,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
* can happen with large stack limits and large mmap() * can happen with large stack limits and large mmap()
* allocations. * allocations.
*/ */
if (addr & ~PAGE_MASK) { if (offset_in_page(addr)) {
VM_BUG_ON(addr != -ENOMEM); VM_BUG_ON(addr != -ENOMEM);
info.flags = 0; info.flags = 0;
info.low_limit = TASK_UNMAPPED_BASE; info.low_limit = TASK_UNMAPPED_BASE;
...@@ -2025,7 +2025,7 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, ...@@ -2025,7 +2025,7 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
if (addr > TASK_SIZE - len) if (addr > TASK_SIZE - len)
return -ENOMEM; return -ENOMEM;
if (addr & ~PAGE_MASK) if (offset_in_page(addr))
return -EINVAL; return -EINVAL;
addr = arch_rebalance_pgtables(addr, len); addr = arch_rebalance_pgtables(addr, len);
...@@ -2535,7 +2535,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len) ...@@ -2535,7 +2535,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
unsigned long end; unsigned long end;
struct vm_area_struct *vma, *prev, *last; struct vm_area_struct *vma, *prev, *last;
if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start) if ((offset_in_page(start)) || start > TASK_SIZE || len > TASK_SIZE-start)
return -EINVAL; return -EINVAL;
len = PAGE_ALIGN(len); len = PAGE_ALIGN(len);
...@@ -2733,7 +2733,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len) ...@@ -2733,7 +2733,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED); error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
if (error & ~PAGE_MASK) if (offset_in_page(error))
return error; return error;
error = mlock_future_check(mm, mm->def_flags, len); error = mlock_future_check(mm, mm->def_flags, len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment