Skip to content

Commit 316389e

Browse files
chleroympe
authored andcommitted
powerpc/syscalls: Simplify do_mmap2()
When shift is nul, operations remain valid so no test needed. And 'ret' is unnecessary. And use IS_ALIGNED() to check alignment, that's more clear. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/373ec500f386374bc5735007df3d3869eac47be1.1624618701.git.christophe.leroy@csgroup.eu
1 parent e084728 commit 316389e

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

arch/powerpc/kernel/syscalls.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,13 @@ static inline long do_mmap2(unsigned long addr, size_t len,
4141
unsigned long prot, unsigned long flags,
4242
unsigned long fd, unsigned long off, int shift)
4343
{
44-
long ret = -EINVAL;
45-
4644
if (!arch_validate_prot(prot, addr))
47-
goto out;
45+
return -EINVAL;
4846

49-
if (shift) {
50-
if (off & ((1 << shift) - 1))
51-
goto out;
52-
off >>= shift;
53-
}
47+
if (!IS_ALIGNED(off, 1 << shift))
48+
return -EINVAL;
5449

55-
ret = ksys_mmap_pgoff(addr, len, prot, flags, fd, off);
56-
out:
57-
return ret;
50+
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> shift);
5851
}
5952

6053
SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,

0 commit comments

Comments
 (0)