summaryrefslogtreecommitdiff
path: root/net/core/net_namespace.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2024-07-11 10:42:33 +0200
committerIngo Molnar <mingo@kernel.org>2024-07-11 10:42:33 +0200
commit011b1134b82c2750d83a299a1369c678845de45a (patch)
treea6a2ba6bfa62b02cb7b00a67c6f449d965140e5a /net/core/net_namespace.c
parentd329605287020c3d1c3b0dadc63d8208e7251382 (diff)
parentddae0ca2a8fe12d0e24ab10ba759c3fbd755ada8 (diff)
Merge branch 'sched/urgent' into sched/core, to pick up fixes and refresh the branch
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'net/core/net_namespace.c')
-rw-r--r--net/core/net_namespace.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 4f7a61688d18..6a823ba906c6 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -693,11 +693,16 @@ EXPORT_SYMBOL_GPL(__put_net);
* get_net_ns - increment the refcount of the network namespace
* @ns: common namespace (net)
*
- * Returns the net's common namespace.
+ * Returns the net's common namespace or ERR_PTR() if ref is zero.
*/
struct ns_common *get_net_ns(struct ns_common *ns)
{
- return &get_net(container_of(ns, struct net, ns))->ns;
+ struct net *net;
+
+ net = maybe_get_net(container_of(ns, struct net, ns));
+ if (net)
+ return &net->ns;
+ return ERR_PTR(-EINVAL);
}
EXPORT_SYMBOL_GPL(get_net_ns);