Skip to content

Commit

Permalink
sched: don't forget to unlock uids_mutex on error paths
Browse files Browse the repository at this point in the history
The commit

 commit 5cb350b
 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>
  • Loading branch information
Pavel Emelyanov authored and Ingo Molnar committed Nov 26, 2007
1 parent 2ffbb83 commit 5e8869b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -355,13 +358,15 @@ 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;
}

if (sched_create_user(new) < 0) {
key_put(new->uid_keyring);
key_put(new->session_keyring);
kmem_cache_free(uid_cachep, new);
uids_mutex_unlock();
return NULL;
}

Expand Down

0 comments on commit 5e8869b

Please sign in to comment.