]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: use check_net()
authorChristian Brauner <brauner@kernel.org>
Thu, 18 Sep 2025 10:11:54 +0000 (12:11 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 19 Sep 2025 14:22:37 +0000 (16:22 +0200)
Don't directly acess the namespace count. There's even a dedicated
helper for this.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
net/core/net_namespace.c

index a6a3de56a81caadb23c9d1b4492ea9cc123d091a..d5e3fd81916316be11d9547432091184df5fb5a6 100644 (file)
@@ -315,7 +315,7 @@ int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp)
 {
        int id;
 
-       if (refcount_read(&net->ns.count) == 0)
+       if (!check_net(net))
                return NETNSA_NSID_NOT_ASSIGNED;
 
        spin_lock(&net->nsid_lock);