]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
locking/atomic, kref: Use kref_get_unless_zero() more
authorPeter Zijlstra <peterz@infradead.org>
Mon, 14 Nov 2016 16:35:56 +0000 (17:35 +0100)
committerIngo Molnar <mingo@kernel.org>
Sat, 14 Jan 2017 10:37:20 +0000 (11:37 +0100)
For some obscure reason apparmor thinks its needs to locally implement
kref primitives that already exist. Stop doing this.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
security/apparmor/include/apparmor.h
security/apparmor/include/policy.h

index 5d721e990876d8b282867523283e4acda7c22930..f067be814626af5055475cec73dabbce2081f326 100644 (file)
@@ -78,12 +78,6 @@ static inline void *kvzalloc(size_t size)
        return __aa_kvmalloc(size, __GFP_ZERO);
 }
 
-/* returns 0 if kref not incremented */
-static inline int kref_get_not0(struct kref *kref)
-{
-       return atomic_inc_not_zero(&kref->refcount);
-}
-
 /**
  * aa_strneq - compare null terminated @str to a non null terminated substring
  * @str: a null terminated string
index 52275f040a5f685e4c20b4d829d47c4c8223644f..46467aaa557b4b0c8d80b11e07d845d867009ba4 100644 (file)
@@ -287,7 +287,7 @@ static inline struct aa_profile *aa_get_profile(struct aa_profile *p)
  */
 static inline struct aa_profile *aa_get_profile_not0(struct aa_profile *p)
 {
-       if (p && kref_get_not0(&p->count))
+       if (p && kref_get_unless_zero(&p->count))
                return p;
 
        return NULL;
@@ -307,7 +307,7 @@ static inline struct aa_profile *aa_get_profile_rcu(struct aa_profile __rcu **p)
        rcu_read_lock();
        do {
                c = rcu_dereference(*p);
-       } while (c && !kref_get_not0(&c->count));
+       } while (c && !kref_get_unless_zero(&c->count));
        rcu_read_unlock();
 
        return c;