Skip to content

Commit 1824cb7

Browse files
0xAXtorvalds
authored andcommitted
mm/nommu: 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: Alexander Kuleshov <kuleshovmail@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b0d61c7 commit 1824cb7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎mm/nommu.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg)
14971497

14981498
if (copy_from_user(&a, arg, sizeof(a)))
14991499
return -EFAULT;
1500-
if (a.offset & ~PAGE_MASK)
1500+
if (offset_in_page(a.offset))
15011501
return -EINVAL;
15021502

15031503
return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
@@ -1653,9 +1653,9 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
16531653
goto erase_whole_vma;
16541654
if (start < vma->vm_start || end > vma->vm_end)
16551655
return -EINVAL;
1656-
if (start & ~PAGE_MASK)
1656+
if (offset_in_page(start))
16571657
return -EINVAL;
1658-
if (end != vma->vm_end && end & ~PAGE_MASK)
1658+
if (end != vma->vm_end && offset_in_page(end))
16591659
return -EINVAL;
16601660
if (start != vma->vm_start && end != vma->vm_end) {
16611661
ret = split_vma(mm, vma, start, 1);
@@ -1736,7 +1736,7 @@ static unsigned long do_mremap(unsigned long addr,
17361736
if (old_len == 0 || new_len == 0)
17371737
return (unsigned long) -EINVAL;
17381738

1739-
if (addr & ~PAGE_MASK)
1739+
if (offset_in_page(addr))
17401740
return -EINVAL;
17411741

17421742
if (flags & MREMAP_FIXED && new_addr != addr)

0 commit comments

Comments
 (0)