Unverified Commit 71dec73f authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12182 netns: Make get_net_ns() handle zero refcount net

parents 5c1bf1ba 29435af6
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -661,11 +661,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);