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 0407762 commit 60e5355Copy full SHA for 60e5355
net/core/net_namespace.c
@@ -657,11 +657,16 @@ EXPORT_SYMBOL_GPL(__put_net);
657
* get_net_ns - increment the refcount of the network namespace
658
* @ns: common namespace (net)
659
*
660
- * Returns the net's common namespace.
+ * Returns the net's common namespace or ERR_PTR() if ref is zero.
661
*/
662
struct ns_common *get_net_ns(struct ns_common *ns)
663
{
664
- return &get_net(container_of(ns, struct net, ns))->ns;
+ struct net *net;
665
+
666
+ net = maybe_get_net(container_of(ns, struct net, ns));
667
+ if (net)
668
+ return &net->ns;
669
+ return ERR_PTR(-EINVAL);
670
}
671
EXPORT_SYMBOL_GPL(get_net_ns);
672
0 commit comments