Thread (71 messages) 71 messages, 7 authors, 2025-09-19

Re: [PATCH v2 11/33] net: use ns_common_init()

From: Christian Brauner <brauner@kernel.org>
Date: 2025-09-15 11:42:12
Also in: linux-block, linux-fsdevel, linux-kselftest, linux-nfs, lkml, netdev
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

On Mon, Sep 15, 2025 at 01:07:06PM +0200, Jan Kara wrote:
On Fri 12-09-25 13:52:34, Christian Brauner wrote:
quoted
Don't cargo-cult the same thing over and over.

Signed-off-by: Christian Brauner <brauner@kernel.org>
...
quoted
@@ -559,7 +572,9 @@ struct net *copy_net_ns(unsigned long flags,
 		goto dec_ucounts;
 	}
 
-	preinit_net(net, user_ns);
+	rv = preinit_net(net, user_ns);
+	if (rv < 0)
+		goto dec_ucounts;
Umm, this seems to be leaking 'net' on error exit.
Sorry about this:
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 5fb7bd8ac45a..466de530c495 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -572,12 +572,13 @@ struct net *copy_net_ns(unsigned long flags,
                goto dec_ucounts;
        }

-       rv = preinit_net(net, user_ns);
-       if (rv < 0)
-               goto dec_ucounts;
        net->ucounts = ucounts;
        get_user_ns(user_ns);

+       rv = preinit_net(net, user_ns);
+       if (rv < 0)
+               goto put_userns;
+
        rv = down_read_killable(&pernet_ops_rwsem);
        if (rv < 0)
                goto put_userns;
Thanks for noticing! Fixed in-tree.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help