Skip to content

Commit

Permalink
ipc/shm: some shmat cleanups
Browse files Browse the repository at this point in the history
Clean up early flag and address some minutia.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Davidlohr Bueso <[email protected]>
Cc: Manfred Spraul <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Davidlohr Bueso authored and torvalds committed May 9, 2017
1 parent 046aa12 commit f0cb880
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ipc/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,11 +1095,11 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
ulong *raddr, unsigned long shmlba)
{
struct shmid_kernel *shp;
unsigned long addr;
unsigned long addr = (unsigned long)shmaddr;
unsigned long size;
struct file *file;
int err;
unsigned long flags;
unsigned long flags = MAP_SHARED;
unsigned long prot;
int acc_mode;
struct ipc_namespace *ns;
Expand All @@ -1111,7 +1111,8 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
err = -EINVAL;
if (shmid < 0)
goto out;
else if ((addr = (ulong)shmaddr)) {

if (addr) {
if (addr & (shmlba - 1)) {
/*
* Round down to the nearest multiple of shmlba.
Expand All @@ -1126,13 +1127,10 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
#endif
goto out;
}
flags = MAP_SHARED | MAP_FIXED;
} else {
if ((shmflg & SHM_REMAP))
goto out;

flags = MAP_SHARED;
}
flags |= MAP_FIXED;
} else if ((shmflg & SHM_REMAP))
goto out;

if (shmflg & SHM_RDONLY) {
prot = PROT_READ;
Expand Down

0 comments on commit f0cb880

Please sign in to comment.