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

mm/mremap: 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 de1741a1
...@@ -401,7 +401,7 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len, ...@@ -401,7 +401,7 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
unsigned long charged = 0; unsigned long charged = 0;
unsigned long map_flags; unsigned long map_flags;
if (new_addr & ~PAGE_MASK) if (offset_in_page(new_addr))
goto out; goto out;
if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len) if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
...@@ -435,11 +435,11 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len, ...@@ -435,11 +435,11 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff + ret = get_unmapped_area(vma->vm_file, new_addr, new_len, vma->vm_pgoff +
((addr - vma->vm_start) >> PAGE_SHIFT), ((addr - vma->vm_start) >> PAGE_SHIFT),
map_flags); map_flags);
if (ret & ~PAGE_MASK) if (offset_in_page(ret))
goto out1; goto out1;
ret = move_vma(vma, addr, old_len, new_len, new_addr, locked); ret = move_vma(vma, addr, old_len, new_len, new_addr, locked);
if (!(ret & ~PAGE_MASK)) if (!(offset_in_page(ret)))
goto out; goto out;
out1: out1:
vm_unacct_memory(charged); vm_unacct_memory(charged);
...@@ -484,7 +484,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, ...@@ -484,7 +484,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
if (flags & MREMAP_FIXED && !(flags & MREMAP_MAYMOVE)) if (flags & MREMAP_FIXED && !(flags & MREMAP_MAYMOVE))
return ret; return ret;
if (addr & ~PAGE_MASK) if (offset_in_page(addr))
return ret; return ret;
old_len = PAGE_ALIGN(old_len); old_len = PAGE_ALIGN(old_len);
...@@ -566,7 +566,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, ...@@ -566,7 +566,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
vma->vm_pgoff + vma->vm_pgoff +
((addr - vma->vm_start) >> PAGE_SHIFT), ((addr - vma->vm_start) >> PAGE_SHIFT),
map_flags); map_flags);
if (new_addr & ~PAGE_MASK) { if (offset_in_page(new_addr)) {
ret = new_addr; ret = new_addr;
goto out; goto out;
} }
...@@ -574,7 +574,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, ...@@ -574,7 +574,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked); ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
} }
out: out:
if (ret & ~PAGE_MASK) { if (offset_in_page(ret)) {
vm_unacct_memory(charged); vm_unacct_memory(charged);
locked = 0; locked = 0;
} }
......
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