Skip to content

Commit

Permalink
mm/nommu: use offset_in_page macro
Browse files Browse the repository at this point in the history
linux/mm.h provides offset_in_page() macro.  Let's use already predefined
macro instead of (addr & ~PAGE_MASK).

Signed-off-by: Alexander Kuleshov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
0xAX authored and torvalds committed Nov 6, 2015
1 parent b0d61c7 commit 1824cb7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg)

if (copy_from_user(&a, arg, sizeof(a)))
return -EFAULT;
if (a.offset & ~PAGE_MASK)
if (offset_in_page(a.offset))
return -EINVAL;

return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
Expand Down Expand Up @@ -1653,9 +1653,9 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
goto erase_whole_vma;
if (start < vma->vm_start || end > vma->vm_end)
return -EINVAL;
if (start & ~PAGE_MASK)
if (offset_in_page(start))
return -EINVAL;
if (end != vma->vm_end && end & ~PAGE_MASK)
if (end != vma->vm_end && offset_in_page(end))
return -EINVAL;
if (start != vma->vm_start && end != vma->vm_end) {
ret = split_vma(mm, vma, start, 1);
Expand Down Expand Up @@ -1736,7 +1736,7 @@ static unsigned long do_mremap(unsigned long addr,
if (old_len == 0 || new_len == 0)
return (unsigned long) -EINVAL;

if (addr & ~PAGE_MASK)
if (offset_in_page(addr))
return -EINVAL;

if (flags & MREMAP_FIXED && new_addr != addr)
Expand Down

0 comments on commit 1824cb7

Please sign in to comment.