Commit 5ba049a5 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by David S. Miller

net: Cleanup in copy_net_ns()

Line up destructors actions in the revers order
to constructors. Next patches will add more actions,
and this will be comfortable, if there is the such
order.
Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
Acked-by: default avatarAndrei Vagin <avagin@virtuozzo.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 98f6c533
...@@ -411,27 +411,25 @@ struct net *copy_net_ns(unsigned long flags, ...@@ -411,27 +411,25 @@ struct net *copy_net_ns(unsigned long flags,
net = net_alloc(); net = net_alloc();
if (!net) { if (!net) {
dec_net_namespaces(ucounts); rv = -ENOMEM;
return ERR_PTR(-ENOMEM); goto dec_ucounts;
} }
refcount_set(&net->passive, 1);
net->ucounts = ucounts;
get_user_ns(user_ns); get_user_ns(user_ns);
rv = mutex_lock_killable(&net_mutex); rv = mutex_lock_killable(&net_mutex);
if (rv < 0) { if (rv < 0)
net_free(net); goto put_userns;
dec_net_namespaces(ucounts);
put_user_ns(user_ns);
return ERR_PTR(rv);
}
net->ucounts = ucounts;
rv = setup_net(net, user_ns); rv = setup_net(net, user_ns);
mutex_unlock(&net_mutex); mutex_unlock(&net_mutex);
if (rv < 0) { if (rv < 0) {
dec_net_namespaces(ucounts); put_userns:
put_user_ns(user_ns); put_user_ns(user_ns);
net_drop_ns(net); net_drop_ns(net);
dec_ucounts:
dec_net_namespaces(ucounts);
return ERR_PTR(rv); return ERR_PTR(rv);
} }
return net; return net;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment