aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorPierre Peiffer <Pierre.Peiffer@bull.net>2007-10-19 02:40:57 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:49 -0400
commit283bb7fada7e33a759d8fc9bd7a44532e4ad420e (patch)
treec6704baf10edd10ca64310f2d168969434bb7dcf /ipc/shm.c
parent3ac88a41ff747b8c2f290f86b5243b2f8fce2cc0 (diff)
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>
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 05c97c7513c2..3818fae625c5 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -433,10 +433,11 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
433 if (IS_ERR(file)) 433 if (IS_ERR(file))
434 goto no_file; 434 goto no_file;
435 435
436 error = -ENOSPC;
437 id = shm_addid(ns, shp); 436 id = shm_addid(ns, shp);
438 if(id == -1) 437 if (id < 0) {
438 error = id;
439 goto no_id; 439 goto no_id;
440 }
440 441
441 shp->shm_cprid = task_tgid_vnr(current); 442 shp->shm_cprid = task_tgid_vnr(current);
442 shp->shm_lprid = 0; 443 shp->shm_lprid = 0;