Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71508
b: refs/heads/master
c: 283bb7f
h: refs/heads/master
v: v3
  • Loading branch information
Pierre Peiffer authored and Linus Torvalds committed Oct 19, 2007
1 parent 7665907 commit 99ccff0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3ac88a41ff747b8c2f290f86b5243b2f8fce2cc0
refs/heads/master: 283bb7fada7e33a759d8fc9bd7a44532e4ad420e
4 changes: 2 additions & 2 deletions trunk/ipc/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions trunk/ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
}

id = ipc_addid(&sem_ids(ns), &sma->sem_perm, ns->sc_semmni);
if(id == -1) {
if (id < 0) {
security_sem_free(sma);
ipc_rcu_putref(sma);
return -ENOSPC;
return id;
}
ns->used_sems += nsems;

Expand Down
5 changes: 3 additions & 2 deletions trunk/ipc/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,11 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
if (IS_ERR(file))
goto no_file;

error = -ENOSPC;
id = shm_addid(ns, shp);
if(id == -1)
if (id < 0) {
error = id;
goto no_id;
}

shp->shm_cprid = task_tgid_vnr(current);
shp->shm_lprid = 0;
Expand Down
16 changes: 11 additions & 5 deletions trunk/ipc/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ int ipc_get_maxid(struct ipc_ids *ids)
* Add an entry 'new' to the IPC ids idr. The permissions object is
* initialised and the first free entry is set up and the id assigned
* is returned. The 'new' entry is returned in a locked state on success.
* On failure the entry is not locked and -1 is returned.
* On failure the entry is not locked and a negative err-code is returned.
*
* Called with ipc_ids.rw_mutex held as a writer.
*/
Expand All @@ -275,11 +275,11 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
size = IPCMNI;

if (ids->in_use >= size)
return -1;
return -ENOSPC;

err = idr_get_new(&ids->ipcs_idr, new, &id);
if (err)
return -1;
return err;

ids->in_use++;

Expand Down Expand Up @@ -311,7 +311,7 @@ int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
struct ipc_ops *ops, struct ipc_params *params)
{
int err;

retry:
err = idr_pre_get(&ids->ipcs_idr, GFP_KERNEL);

if (!err)
Expand All @@ -321,6 +321,9 @@ int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
err = ops->getnew(ns, params);
up_write(&ids->rw_mutex);

if (err == -EAGAIN)
goto retry;

return err;
}

Expand Down Expand Up @@ -374,7 +377,7 @@ int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
struct kern_ipc_perm *ipcp;
int flg = params->flg;
int err;

retry:
err = idr_pre_get(&ids->ipcs_idr, GFP_KERNEL);

/*
Expand Down Expand Up @@ -411,6 +414,9 @@ int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
}
up_write(&ids->rw_mutex);

if (err == -EAGAIN)
goto retry;

return err;
}

Expand Down

0 comments on commit 99ccff0

Please sign in to comment.