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