summaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-07-12 14:35:25 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-12 16:26:02 -0700
commit42e618f77dabc82c697915c193d729e9d16e2a75 (patch)
treeb473212b03b2c689aef6aa27beee310fdd15824c /ipc/shm.c
parent3d3653f9732c73feb8c4addfc1cbdaa292a399fa (diff)
downloadlinux-42e618f77dabc82c697915c193d729e9d16e2a75.tar.gz
linux-42e618f77dabc82c697915c193d729e9d16e2a75.tar.bz2
linux-42e618f77dabc82c697915c193d729e9d16e2a75.zip
ipc/shm: remove special shm_alloc/free
There is nothing special about the shm_alloc/free routines any more, so remove them to make code more readable. [manfred@colorfullife.com: Rediff, to continue to keep rcu for free calls after a successful security_shm_alloc()] Link: http://lkml.kernel.org/r/20170525185107.12869-18-manfred@colorfullife.com Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Manfred Spraul <manfred@colorfullife.com> Cc: Davidlohr Bueso <dave@stgolabs.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index d1988ef821a1..28a444861a8f 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -172,11 +172,6 @@ static inline void shm_lock_by_ptr(struct shmid_kernel *ipcp)
ipc_lock_object(&ipcp->shm_perm);
}
-static void __shm_free(struct shmid_kernel *shp)
-{
- kvfree(shp);
-}
-
static void shm_rcu_free(struct rcu_head *head)
{
struct kern_ipc_perm *ptr = container_of(head, struct kern_ipc_perm,
@@ -184,7 +179,7 @@ static void shm_rcu_free(struct rcu_head *head)
struct shmid_kernel *shp = container_of(ptr, struct shmid_kernel,
shm_perm);
security_shm_free(shp);
- __shm_free(shp);
+ kvfree(shp);
}
static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s)
@@ -518,17 +513,6 @@ static const struct vm_operations_struct shm_vm_ops = {
#endif
};
-static struct shmid_kernel *shm_alloc(void)
-{
- struct shmid_kernel *shp;
-
- shp = kvmalloc(sizeof(*shp), GFP_KERNEL);
- if (unlikely(!shp))
- return NULL;
-
- return shp;
-}
-
/**
* newseg - Create a new shared memory segment
* @ns: namespace
@@ -558,8 +542,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
ns->shm_tot + numpages > ns->shm_ctlall)
return -ENOSPC;
- shp = shm_alloc();
- if (!shp)
+ shp = kvmalloc(sizeof(*shp), GFP_KERNEL);
+ if (unlikely(!shp))
return -ENOMEM;
shp->shm_perm.key = key;
@@ -569,7 +553,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
shp->shm_perm.security = NULL;
error = security_shm_alloc(shp);
if (error) {
- __shm_free(shp);
+ kvfree(shp);
return error;
}