IPC: fix error case when idr-cache is empty in ipcget()

With the use of idr to store the ipc, the case where the idr cache is
empty, when idr_get_new is called (this may happen even if we call
idr_pre_get() before), is not well handled: it lets
semget()/shmget()/msgget() return ENOSPC when this cache is empty, what 1.
does not reflect the facts and 2.  does not conform to the man(s).

This patch fixes this by retrying the whole process of allocation in this case.

Signed-off-by: Pierre Peiffer <pierre.peiffer@bull.net>
Cc: Nadia Derbey <Nadia.Derbey@bull.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Pierre Peiffer 2007-10-18 23:40:57 -07:00 committed by Linus Torvalds
parent 3ac88a41ff
commit 283bb7fada
4 changed files with 18 additions and 11 deletions

View file

@ -203,10 +203,10 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
* ipc_addid() locks msq
*/
id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni);
if (id == -1) {
if (id < 0) {
security_msg_queue_free(msq);
ipc_rcu_putref(msq);
return -ENOSPC;
return id;
}
msq->q_perm.id = msg_buildid(id, msq->q_perm.seq);