Skip to contentSkip to conversation

Don't forget to unlock uids_mutex on error paths

PATCH In review Pavel Emelyanov 3 participants 3 messages Nov 21, 2007 – Nov 23, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Don't forget to unlock uids_mutex on error paths

The commit

commit 5cb350baf580017da38199625b7365b1763d7180

Author: Dhaval Giani <[email protected]>
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.

---

kernel/user.c +6 -1
index 56327ee..3549c4b 100644
@@ -343,8 +343,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);
@@ -361,6 +364,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;
 		}
 
@@ -368,6 +372,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;
 		}
 
Signature · 1 line
1.5.3.4
Acked-by on v1 1/2
#1 lore raw
Quoted 12 lines · Pavel Emelyanov

The commit

commit 5cb350baf580017da38199625b7365b1763d7180

Author: Dhaval Giani <[email protected]>
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.

Thanks for catching it. Looks good to me. Ingo, could you please pick these up?

Quoted 1 line
Signature · 2 lines
regards,
Dhaval
#2 lore raw
Quoted 7 lines · Dhaval Giani
Quoted 6 lines · Pavel Emelyanov

The commit

commit 5cb350baf580017da38199625b7365b1763d7180

Author: Dhaval Giani <[email protected]>
Date:   Mon Oct 15 17:00:14 2007 +0200
Quoted 5 lines
Quoted 5 lines

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.

oops!

Quoted 2 lines

Thanks for catching it. Looks good to me. Ingo, could you please pick these up?

yep - added.

Ingo