Skip to content

Commit

Permalink
powerpc/syscalls: Simplify do_mmap2()
Browse files Browse the repository at this point in the history
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 <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/373ec500f386374bc5735007df3d3869eac47be1.1624618701.git.christophe.leroy@csgroup.eu
  • Loading branch information
Christophe Leroy authored and Michael Ellerman committed Aug 25, 2021
1 parent e084728 commit 316389e
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions arch/powerpc/kernel/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,13 @@ static inline long do_mmap2(unsigned long addr, size_t len,
unsigned long prot, unsigned long flags,
unsigned long fd, unsigned long off, int shift)
{
long ret = -EINVAL;

if (!arch_validate_prot(prot, addr))
goto out;
return -EINVAL;

if (shift) {
if (off & ((1 << shift) - 1))
goto out;
off >>= shift;
}
if (!IS_ALIGNED(off, 1 << shift))
return -EINVAL;

ret = ksys_mmap_pgoff(addr, len, prot, flags, fd, off);
out:
return ret;
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> shift);
}

SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
Expand Down

0 comments on commit 316389e

Please sign in to comment.