diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-07 01:35:03 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-07 01:35:03 +0200 |
commit | fccfb9950836524d79260448fba6131f6b1d73c3 (patch) | |
tree | a6fef32e330852138d9e7bd12d7b3dd97c4360c3 /kernel/ucount.c | |
parent | generic ...copy_..._user primitives (diff) | |
parent | mm, page_alloc: Add missing check for memory holes (diff) | |
download | linux-fccfb9950836524d79260448fba6131f6b1d73c3.tar.xz linux-fccfb9950836524d79260448fba6131f6b1d73c3.zip |
Merge commit 'b4fb8f66f1ae2e167d06c12d018025a8d4d3ba7e' into uaccess.ia64
backmerge of mainline ia64 fix
Diffstat (limited to 'kernel/ucount.c')
-rw-r--r-- | kernel/ucount.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/kernel/ucount.c b/kernel/ucount.c index 62630a40ab3a..b4eeee03934f 100644 --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -144,7 +144,7 @@ static struct ucounts *get_ucounts(struct user_namespace *ns, kuid_t uid) new->ns = ns; new->uid = uid; - atomic_set(&new->count, 0); + new->count = 0; spin_lock_irq(&ucounts_lock); ucounts = find_ucounts(ns, uid, hashent); @@ -155,8 +155,10 @@ static struct ucounts *get_ucounts(struct user_namespace *ns, kuid_t uid) ucounts = new; } } - if (!atomic_add_unless(&ucounts->count, 1, INT_MAX)) + if (ucounts->count == INT_MAX) ucounts = NULL; + else + ucounts->count += 1; spin_unlock_irq(&ucounts_lock); return ucounts; } @@ -165,13 +167,15 @@ static void put_ucounts(struct ucounts *ucounts) { unsigned long flags; - if (atomic_dec_and_test(&ucounts->count)) { - spin_lock_irqsave(&ucounts_lock, flags); + spin_lock_irqsave(&ucounts_lock, flags); + ucounts->count -= 1; + if (!ucounts->count) hlist_del_init(&ucounts->node); - spin_unlock_irqrestore(&ucounts_lock, flags); + else + ucounts = NULL; + spin_unlock_irqrestore(&ucounts_lock, flags); - kfree(ucounts); - } + kfree(ucounts); } static inline bool atomic_inc_below(atomic_t *v, int u) |