diff options
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r-- | net/core/rtnetlink.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 02cf848f71d2..ddbdde82a700 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -1368,25 +1368,14 @@ static int rtnetlink_net_init(struct net *net) | |||
1368 | rtnetlink_rcv, &rtnl_mutex, THIS_MODULE); | 1368 | rtnetlink_rcv, &rtnl_mutex, THIS_MODULE); |
1369 | if (!sk) | 1369 | if (!sk) |
1370 | return -ENOMEM; | 1370 | return -ENOMEM; |
1371 | |||
1372 | /* Don't hold an extra reference on the namespace */ | ||
1373 | put_net(sk->sk_net); | ||
1374 | net->rtnl = sk; | 1371 | net->rtnl = sk; |
1375 | return 0; | 1372 | return 0; |
1376 | } | 1373 | } |
1377 | 1374 | ||
1378 | static void rtnetlink_net_exit(struct net *net) | 1375 | static void rtnetlink_net_exit(struct net *net) |
1379 | { | 1376 | { |
1380 | struct sock *sk = net->rtnl; | 1377 | netlink_kernel_release(net->rtnl); |
1381 | if (sk) { | 1378 | net->rtnl = NULL; |
1382 | /* At the last minute lie and say this is a socket for the | ||
1383 | * initial network namespace. So the socket will be safe to | ||
1384 | * free. | ||
1385 | */ | ||
1386 | sk->sk_net = get_net(&init_net); | ||
1387 | netlink_kernel_release(net->rtnl); | ||
1388 | net->rtnl = NULL; | ||
1389 | } | ||
1390 | } | 1379 | } |
1391 | 1380 | ||
1392 | static struct pernet_operations rtnetlink_net_ops = { | 1381 | static struct pernet_operations rtnetlink_net_ops = { |