ipc: drop non-RCU allocation

The only users of ipc_alloc() were ipc_rcu_alloc() and the on-heap
sem_io fall-back memory.  Better to just open-code these to make things
easier to read.

[[email protected]: Rediff due to inclusion of memset() into ipc_rcu_alloc()]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: Manfred Spraul <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Kees Cook 2017-07-12 14:34:47 -07:00 • committed by Linus Torvalds
commit f8dbe8d290
3 changed files with 6 additions and 33 deletions

View file

@ -394,29 +394,6 @@ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp)
ipcp->deleted = true;
}
/**
* ipc_alloc - allocate ipc space
* @size: size desired
*
* Allocate memory from the appropriate pools and return a pointer to it.
* NULL is returned if the allocation fails
*/
void *ipc_alloc(int size)
{
return kvmalloc(size, GFP_KERNEL);
}
/**
* ipc_free - free ipc space
* @ptr: pointer returned by ipc_alloc
*
* Free a block created with ipc_alloc().
*/
void ipc_free(void *ptr)
{
kvfree(ptr);
}
/**
* ipc_rcu_alloc - allocate ipc space
* @size: size desired
@ -429,7 +406,7 @@ struct kern_ipc_perm *ipc_rcu_alloc(int size)
/*
* We prepend the allocation with the rcu struct
*/
struct kern_ipc_perm *out = ipc_alloc(size);
struct kern_ipc_perm *out = kvmalloc(size, GFP_KERNEL);
if (unlikely(!out))
return NULL;