]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ns: don't skip active reference count initialization
authorChristian Brauner <brauner@kernel.org>
Sun, 9 Nov 2025 21:11:22 +0000 (22:11 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 10 Nov 2025 09:20:50 +0000 (10:20 +0100)
Don't skip active reference count initialization for initial namespaces.
Doing this will break network namespace active reference counting.

Link: https://patch.msgid.link/20251109-namespace-6-19-fixes-v1-1-ae8a4ad5a3b3@kernel.org
Fixes: 3a18f809184b ("ns: add active reference count")
Signed-off-by: Christian Brauner <brauner@kernel.org>
kernel/nscommon.c

index 6fe1c747fa46bbb6a7a0d14e1e38f86472058b4d..d67ae7ad775919bd71747887c7c73ab74fb94e83 100644 (file)
@@ -54,7 +54,7 @@ static void ns_debug(struct ns_common *ns, const struct proc_ns_operations *ops)
 
 int __ns_common_init(struct ns_common *ns, u32 ns_type, const struct proc_ns_operations *ops, int inum)
 {
-       int ret;
+       int ret = 0;
 
        refcount_set(&ns->__ns_ref, 1);
        ns->stashed = NULL;
@@ -74,11 +74,10 @@ int __ns_common_init(struct ns_common *ns, u32 ns_type, const struct proc_ns_ope
        ns_debug(ns, ops);
 #endif
 
-       if (inum) {
+       if (inum)
                ns->inum = inum;
-               return 0;
-       }
-       ret = proc_alloc_inum(&ns->inum);
+       else
+               ret = proc_alloc_inum(&ns->inum);
        if (ret)
                return ret;
        /*