Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1577952
| From | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/4] ipc/shm: some shmat cleanups |
| Date | 2017-02-09 22:00 +0100 |
| Message-ID | <t93YS-2u7-29@gated-at.bofh.it> (permalink) |
| References | <t93YS-2u7-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
... cleans up early flag and address minutia.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
ipc/shm.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/ipc/shm.c b/ipc/shm.c
index 6b3769967789..9c960241e214 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -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;
@@ -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.
@@ -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;
--
2.6.6
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -tip 0/4] ipc/shm: moar updates for v4.11 Davidlohr Bueso <dave@stgolabs.net> - 2017-02-09 22:00 +0100 [PATCH 2/4] ipc/shm: some shmat cleanups Davidlohr Bueso <dave@stgolabs.net> - 2017-02-09 22:00 +0100 [PATCH 3/4] sysv,ipc: cacheline align kern_ipc_perm Davidlohr Bueso <dave@stgolabs.net> - 2017-02-09 22:00 +0100
csiph-web