We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9f30f1f commit cb7f811Copy full SHA for cb7f811
net/core/net_namespace.c
@@ -651,11 +651,16 @@ EXPORT_SYMBOL_GPL(__put_net);
651
* get_net_ns - increment the refcount of the network namespace
652
* @ns: common namespace (net)
653
*
654
- * Returns the net's common namespace.
+ * Returns the net's common namespace or ERR_PTR() if ref is zero.
655
*/
656
struct ns_common *get_net_ns(struct ns_common *ns)
657
{
658
- return &get_net(container_of(ns, struct net, ns))->ns;
+ struct net *net;
659
+
660
+ net = maybe_get_net(container_of(ns, struct net, ns));
661
+ if (net)
662
+ return &net->ns;
663
+ return ERR_PTR(-EINVAL);
664
}
665
EXPORT_SYMBOL_GPL(get_net_ns);
666
0 commit comments