]> git.karo-electronics.de Git - linux-beck.git/commitdiff
sched: don't forget to unlock uids_mutex on error paths
authorPavel Emelyanov <xemul@openvz.org>
Mon, 26 Nov 2007 20:21:49 +0000 (21:21 +0100)
committerIngo Molnar <mingo@elte.hu>
Mon, 26 Nov 2007 20:21:49 +0000 (21:21 +0100)
The commit

 commit 5cb350baf580017da38199625b7365b1763d7180
 Author: Dhaval Giani <dhaval@linux.vnet.ibm.com>
 Date:   Mon Oct 15 17:00:14 2007 +0200

    sched: group scheduling, sysfs tunables

introduced the uids_mutex and the helpers to lock/unlock it.
Unfortunately, the error paths of alloc_uid() were not patched
to unlock it.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/user.c

index 0f3aa0234107e3742b7727565b8343539df122c9..8320a87f3e5a11f11e2159488cf2dc3f6d9371d3 100644 (file)
@@ -337,8 +337,11 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
                struct user_struct *new;
 
                new = kmem_cache_alloc(uid_cachep, GFP_KERNEL);
-               if (!new)
+               if (!new) {
+                       uids_mutex_unlock();
                        return NULL;
+               }
+
                new->uid = uid;
                atomic_set(&new->__count, 1);
                atomic_set(&new->processes, 0);
@@ -355,6 +358,7 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
 
                if (alloc_uid_keyring(new, current) < 0) {
                        kmem_cache_free(uid_cachep, new);
+                       uids_mutex_unlock();
                        return NULL;
                }
 
@@ -362,6 +366,7 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
                        key_put(new->uid_keyring);
                        key_put(new->session_keyring);
                        kmem_cache_free(uid_cachep, new);
+                       uids_mutex_unlock();
                        return NULL;
                }