* [PATCH] kernel/user.c: clean up some leftover code
@ 2019-04-24 20:04 Rasmus Villemoes
0 siblings, 0 replies; only message in thread
From: Rasmus Villemoes @ 2019-04-24 20:04 UTC (permalink / raw)
To: Andrew Morton, Peter Zijlstra (Intel); +Cc: Rasmus Villemoes, linux-kernel
The out_unlock label is misleading; no unlocking happens after it, so
just return NULL directly. Also, nothing between the
kmem_cache_zalloc() that creates new and the two key_put() can
initialize new->uid_keyring or new->session_keyring, so those calls
are no-ops.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
kernel/user.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/kernel/user.c b/kernel/user.c
index 0df9b1640b2a..88b834f0eebc 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -185,7 +185,7 @@ struct user_struct *alloc_uid(kuid_t uid)
if (!up) {
new = kmem_cache_zalloc(uid_cachep, GFP_KERNEL);
if (!new)
- goto out_unlock;
+ return NULL;
new->uid = uid;
refcount_set(&new->__count, 1);
@@ -199,8 +199,6 @@ struct user_struct *alloc_uid(kuid_t uid)
spin_lock_irq(&uidhash_lock);
up = uid_hash_find(uid, hashent);
if (up) {
- key_put(new->uid_keyring);
- key_put(new->session_keyring);
kmem_cache_free(uid_cachep, new);
} else {
uid_hash_insert(new, hashent);
@@ -210,9 +208,6 @@ struct user_struct *alloc_uid(kuid_t uid)
}
return up;
-
-out_unlock:
- return NULL;
}
static int __init uid_cache_init(void)
--
2.20.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-04-24 20:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 20:04 [PATCH] kernel/user.c: clean up some leftover code Rasmus Villemoes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®