Merge branch 'master' of git://git.infradead.org/users/eparis/selinux into for-linus
[firefly-linux-kernel-4.4.55.git] / security / selinux / avc.c
index ce742f1778e1a62ea5fb36b29f8366b4658219ab..fcb89cb0f2235b5801004eba9ada05738d858f58 100644 (file)
 #define AVC_CACHE_RECLAIM              16
 
 #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
-#define avc_cache_stats_incr(field)                            \
-do {                                                           \
-       per_cpu(avc_cache_stats, get_cpu()).field++;            \
-       put_cpu();                                              \
-} while (0)
+#define avc_cache_stats_incr(field)    this_cpu_inc(avc_cache_stats.field)
 #else
 #define avc_cache_stats_incr(field)    do {} while (0)
 #endif
@@ -347,11 +343,10 @@ static struct avc_node *avc_lookup(u32 ssid, u32 tsid, u16 tclass)
        node = avc_search_node(ssid, tsid, tclass);
 
        if (node)
-               avc_cache_stats_incr(hits);
-       else
-               avc_cache_stats_incr(misses);
+               return node;
 
-       return node;
+       avc_cache_stats_incr(misses);
+       return NULL;
 }
 
 static int avc_latest_notif_update(int seqno, int is_insert)
@@ -769,7 +764,7 @@ int avc_has_perm_noaudit(u32 ssid, u32 tsid,
        rcu_read_lock();
 
        node = avc_lookup(ssid, tsid, tclass);
-       if (!node) {
+       if (unlikely(!node)) {
                rcu_read_unlock();
 
                if (in_avd)