aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
Diffstat (limited to 'ipc')
-rw-r--r--ipc/util.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ipc/util.c b/ipc/util.c
index c8a76701b6c9..5a1808c774a2 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -268,9 +268,17 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
268 if (ids->in_use >= size) 268 if (ids->in_use >= size)
269 return -ENOSPC; 269 return -ENOSPC;
270 270
271 spin_lock_init(&new->lock);
272 new->deleted = 0;
273 rcu_read_lock();
274 spin_lock(&new->lock);
275
271 err = idr_get_new(&ids->ipcs_idr, new, &id); 276 err = idr_get_new(&ids->ipcs_idr, new, &id);
272 if (err) 277 if (err) {
278 spin_unlock(&new->lock);
279 rcu_read_unlock();
273 return err; 280 return err;
281 }
274 282
275 ids->in_use++; 283 ids->in_use++;
276 284
@@ -283,10 +291,6 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
283 ids->seq = 0; 291 ids->seq = 0;
284 292
285 new->id = ipc_buildid(id, new->seq); 293 new->id = ipc_buildid(id, new->seq);
286 spin_lock_init(&new->lock);
287 new->deleted = 0;
288 rcu_read_lock();
289 spin_lock(&new->lock);
290 return id; 294 return id;
291} 295}
292 296