We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 72be785 commit d88dd56Copy full SHA for d88dd56
net/core/net_namespace.c
@@ -693,11 +693,16 @@ EXPORT_SYMBOL_GPL(__put_net);
693
* get_net_ns - increment the refcount of the network namespace
694
* @ns: common namespace (net)
695
*
696
- * Returns the net's common namespace.
+ * Returns the net's common namespace or ERR_PTR() if ref is zero.
697
*/
698
struct ns_common *get_net_ns(struct ns_common *ns)
699
{
700
- return &get_net(container_of(ns, struct net, ns))->ns;
+ struct net *net;
701
+
702
+ net = maybe_get_net(container_of(ns, struct net, ns));
703
+ if (net)
704
+ return &net->ns;
705
+ return ERR_PTR(-EINVAL);
706
}
707
EXPORT_SYMBOL_GPL(get_net_ns);
708
0 commit comments