Merge branch 'misc.namei' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-microblaze.git] / net / netfilter / nft_ct.c
index 337e22d..99b1de1 100644 (file)
@@ -41,6 +41,7 @@ struct nft_ct_helper_obj  {
 #ifdef CONFIG_NF_CONNTRACK_ZONES
 static DEFINE_PER_CPU(struct nf_conn *, nft_ct_pcpu_template);
 static unsigned int nft_ct_pcpu_template_refcnt __read_mostly;
+static DEFINE_MUTEX(nft_ct_pcpu_mutex);
 #endif
 
 static u64 nft_ct_get_eval_counter(const struct nf_conn_counter *c,
@@ -525,8 +526,10 @@ static void __nft_ct_set_destroy(const struct nft_ctx *ctx, struct nft_ct *priv)
 #endif
 #ifdef CONFIG_NF_CONNTRACK_ZONES
        case NFT_CT_ZONE:
+               mutex_lock(&nft_ct_pcpu_mutex);
                if (--nft_ct_pcpu_template_refcnt == 0)
                        nft_ct_tmpl_put_pcpu();
+               mutex_unlock(&nft_ct_pcpu_mutex);
                break;
 #endif
        default:
@@ -564,9 +567,13 @@ static int nft_ct_set_init(const struct nft_ctx *ctx,
 #endif
 #ifdef CONFIG_NF_CONNTRACK_ZONES
        case NFT_CT_ZONE:
-               if (!nft_ct_tmpl_alloc_pcpu())
+               mutex_lock(&nft_ct_pcpu_mutex);
+               if (!nft_ct_tmpl_alloc_pcpu()) {
+                       mutex_unlock(&nft_ct_pcpu_mutex);
                        return -ENOMEM;
+               }
                nft_ct_pcpu_template_refcnt++;
+               mutex_unlock(&nft_ct_pcpu_mutex);
                len = sizeof(u16);
                break;
 #endif