USB: serial: omninet: fix reference leaks at open
[pandora-kernel.git] / ipc / util.c
index 5c0d289..e4c9377 100644 (file)
@@ -264,6 +264,10 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
        rcu_read_lock();
        spin_lock(&new->lock);
 
+       current_euid_egid(&euid, &egid);
+       new->cuid = new->uid = euid;
+       new->gid = new->cgid = egid;
+
        err = idr_get_new(&ids->ipcs_idr, new, &id);
        if (err) {
                spin_unlock(&new->lock);
@@ -273,10 +277,6 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
 
        ids->in_use++;
 
-       current_euid_egid(&euid, &egid);
-       new->cuid = new->uid = euid;
-       new->gid = new->cgid = egid;
-
        new->seq = ids->seq++;
        if(ids->seq > ids->seq_max)
                ids->seq = 0;
@@ -579,19 +579,6 @@ static void ipc_schedule_free(struct rcu_head *head)
        schedule_work(&sched->work);
 }
 
-/**
- * ipc_immediate_free - free ipc + rcu space
- * @head: RCU callback structure that contains pointer to be freed
- *
- * Free from the RCU callback context.
- */
-static void ipc_immediate_free(struct rcu_head *head)
-{
-       struct ipc_rcu_grace *free =
-               container_of(head, struct ipc_rcu_grace, rcu);
-       kfree(free);
-}
-
 void ipc_rcu_putref(void *ptr)
 {
        if (--container_of(ptr, struct ipc_rcu_hdr, data)->refcount > 0)
@@ -601,8 +588,7 @@ void ipc_rcu_putref(void *ptr)
                call_rcu(&container_of(ptr, struct ipc_rcu_grace, data)->rcu,
                                ipc_schedule_free);
        } else {
-               call_rcu(&container_of(ptr, struct ipc_rcu_grace, data)->rcu,
-                               ipc_immediate_free);
+               kfree_rcu(container_of(ptr, struct ipc_rcu_grace, data), rcu);
        }
 }