patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / kernel / user.c
index 75faf3d..209a7d1 100644 (file)
@@ -64,9 +64,20 @@ static inline struct user_struct *uid_hash_find(xid_t xid, uid_t uid, struct lis
        return NULL;
 }
 
+/*
+ * Locate the user_struct for the passed UID.  If found, take a ref on it.  The
+ * caller must undo that ref with free_uid().
+ *
+ * If the user_struct could not be found, return NULL.
+ */
 struct user_struct *find_user(xid_t xid, uid_t uid)
 {
-       return uid_hash_find(xid, uid, uidhashentry(xid, uid));
+       struct user_struct *ret;
+
+       spin_lock(&uidhash_lock);
+       ret = uid_hash_find(xid, uid, uidhashentry(xid, uid));
+       spin_unlock(&uidhash_lock);
+       return ret;
 }
 
 void free_uid(struct user_struct *up)
@@ -139,10 +150,7 @@ static int __init uid_cache_init(void)
        int n;
 
        uid_cachep = kmem_cache_create("uid_cache", sizeof(struct user_struct),
-                                      0,
-                                      SLAB_HWCACHE_ALIGN, NULL, NULL);
-       if(!uid_cachep)
-               panic("Cannot create uid taskcount SLAB cache\n");
+                       0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
 
        for(n = 0; n < UIDHASH_SZ; ++n)
                INIT_LIST_HEAD(uidhash_table + n);