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 f897d71 commit ef0394cCopy full SHA for ef0394c
net/core/net_namespace.c
@@ -670,11 +670,16 @@ EXPORT_SYMBOL_GPL(__put_net);
670
* get_net_ns - increment the refcount of the network namespace
671
* @ns: common namespace (net)
672
*
673
- * Returns the net's common namespace.
+ * Returns the net's common namespace or ERR_PTR() if ref is zero.
674
*/
675
struct ns_common *get_net_ns(struct ns_common *ns)
676
{
677
- return &get_net(container_of(ns, struct net, ns))->ns;
+ struct net *net;
678
+
679
+ net = maybe_get_net(container_of(ns, struct net, ns));
680
+ if (net)
681
+ return &net->ns;
682
+ return ERR_PTR(-EINVAL);
683
}
684
EXPORT_SYMBOL_GPL(get_net_ns);
685
0 commit comments