diff options
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r-- | net/netlink/af_netlink.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index e6b636d53633..524e826bb976 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -1372,8 +1372,7 @@ netlink_kernel_create(struct net *net, int unit, unsigned int groups, | |||
1372 | goto out_sock_release_nosk; | 1372 | goto out_sock_release_nosk; |
1373 | 1373 | ||
1374 | sk = sock->sk; | 1374 | sk = sock->sk; |
1375 | put_net(sk->sk_net); | 1375 | sk_change_net(sk, net); |
1376 | sk->sk_net = net; | ||
1377 | 1376 | ||
1378 | if (groups < 32) | 1377 | if (groups < 32) |
1379 | groups = 32; | 1378 | groups = 32; |
@@ -1421,20 +1420,7 @@ EXPORT_SYMBOL(netlink_kernel_create); | |||
1421 | void | 1420 | void |
1422 | netlink_kernel_release(struct sock *sk) | 1421 | netlink_kernel_release(struct sock *sk) |
1423 | { | 1422 | { |
1424 | /* | 1423 | sk_release_kernel(sk); |
1425 | * Last sock_put should drop referrence to sk->sk_net. It has already | ||
1426 | * been dropped in netlink_kernel_create. Taking referrence to stopping | ||
1427 | * namespace is not an option. | ||
1428 | * Take referrence to a socket to remove it from netlink lookup table | ||
1429 | * _alive_ and after that destroy it in the context of init_net. | ||
1430 | */ | ||
1431 | if (sk == NULL || sk->sk_socket == NULL) | ||
1432 | return; | ||
1433 | |||
1434 | sock_hold(sk); | ||
1435 | sock_release(sk->sk_socket); | ||
1436 | sk->sk_net = get_net(&init_net); | ||
1437 | sock_put(sk); | ||
1438 | } | 1424 | } |
1439 | EXPORT_SYMBOL(netlink_kernel_release); | 1425 | EXPORT_SYMBOL(netlink_kernel_release); |
1440 | 1426 | ||