diff options
author | Alexander Kuleshov <kuleshovmail@gmail.com> | 2015-11-05 21:46:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-11-05 22:34:48 -0500 |
commit | de1741a1333ea37694dddf7c94aa4cf2d0e58912 (patch) | |
tree | 3b327e0d452c0f835624c6cee9df0c79003f71f0 /mm/mmap.c | |
parent | 891c49abfb097bbd7024b4072dd1c8e1c995d3ec (diff) |
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: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1302,7 +1302,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr, | |||
1302 | * that it represents a valid section of the address space. | 1302 | * that it represents a valid section of the address space. |
1303 | */ | 1303 | */ |
1304 | addr = get_unmapped_area(file, addr, len, pgoff, flags); | 1304 | addr = get_unmapped_area(file, addr, len, pgoff, flags); |
1305 | if (addr & ~PAGE_MASK) | 1305 | if (offset_in_page(addr)) |
1306 | return addr; | 1306 | return addr; |
1307 | 1307 | ||
1308 | /* Do simple checking here so the lower-level routines won't have | 1308 | /* 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 | 1473 | ||
1474 | if (copy_from_user(&a, arg, sizeof(a))) | 1474 | if (copy_from_user(&a, arg, sizeof(a))) |
1475 | return -EFAULT; | 1475 | return -EFAULT; |
1476 | if (a.offset & ~PAGE_MASK) | 1476 | if (offset_in_page(a.offset)) |
1477 | return -EINVAL; | 1477 | return -EINVAL; |
1478 | 1478 | ||
1479 | return sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, | 1479 | 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 | * can happen with large stack limits and large mmap() | 1989 | * can happen with large stack limits and large mmap() |
1990 | * allocations. | 1990 | * allocations. |
1991 | */ | 1991 | */ |
1992 | if (addr & ~PAGE_MASK) { | 1992 | if (offset_in_page(addr)) { |
1993 | VM_BUG_ON(addr != -ENOMEM); | 1993 | VM_BUG_ON(addr != -ENOMEM); |
1994 | info.flags = 0; | 1994 | info.flags = 0; |
1995 | info.low_limit = TASK_UNMAPPED_BASE; | 1995 | info.low_limit = TASK_UNMAPPED_BASE; |
@@ -2025,7 +2025,7 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, | |||
2025 | 2025 | ||
2026 | if (addr > TASK_SIZE - len) | 2026 | if (addr > TASK_SIZE - len) |
2027 | return -ENOMEM; | 2027 | return -ENOMEM; |
2028 | if (addr & ~PAGE_MASK) | 2028 | if (offset_in_page(addr)) |
2029 | return -EINVAL; | 2029 | return -EINVAL; |
2030 | 2030 | ||
2031 | addr = arch_rebalance_pgtables(addr, len); | 2031 | addr = arch_rebalance_pgtables(addr, len); |
@@ -2535,7 +2535,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len) | |||
2535 | unsigned long end; | 2535 | unsigned long end; |
2536 | struct vm_area_struct *vma, *prev, *last; | 2536 | struct vm_area_struct *vma, *prev, *last; |
2537 | 2537 | ||
2538 | if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start) | 2538 | if ((offset_in_page(start)) || start > TASK_SIZE || len > TASK_SIZE-start) |
2539 | return -EINVAL; | 2539 | return -EINVAL; |
2540 | 2540 | ||
2541 | len = PAGE_ALIGN(len); | 2541 | len = PAGE_ALIGN(len); |
@@ -2733,7 +2733,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len) | |||
2733 | flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; | 2733 | flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; |
2734 | 2734 | ||
2735 | error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED); | 2735 | error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED); |
2736 | if (error & ~PAGE_MASK) | 2736 | if (offset_in_page(error)) |
2737 | return error; | 2737 | return error; |
2738 | 2738 | ||
2739 | error = mlock_future_check(mm, mm->def_flags, len); | 2739 | error = mlock_future_check(mm, mm->def_flags, len); |