Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android
[firefly-linux-kernel-4.4.55.git] / net / core / net_namespace.c
index 2c2eb1b629b11d6911abfa885549e32d927815a6..2e9a1c2818c7ab2d378cd112e70cb27ba9f369a3 100644 (file)
@@ -217,6 +217,8 @@ int peernet2id_alloc(struct net *net, struct net *peer)
        bool alloc;
        int id;
 
+       if (atomic_read(&net->count) == 0)
+               return NETNSA_NSID_NOT_ASSIGNED;
        spin_lock_irqsave(&net->nsid_lock, flags);
        alloc = atomic_read(&peer->count) == 0 ? false : true;
        id = __peernet2id_alloc(net, peer, &alloc);