diff options
Diffstat (limited to 'net/l2tp')
-rw-r--r-- | net/l2tp/l2tp_core.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 45373fee38c5..e841ef2a68a5 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c | |||
@@ -1412,19 +1412,21 @@ static void l2tp_tunnel_del_work(struct work_struct *work) | |||
1412 | return; | 1412 | return; |
1413 | 1413 | ||
1414 | sock = sk->sk_socket; | 1414 | sock = sk->sk_socket; |
1415 | BUG_ON(!sock); | ||
1416 | 1415 | ||
1417 | /* If the tunnel socket was created directly by the kernel, use the | 1416 | /* If the tunnel socket was created by userspace, then go through the |
1418 | * sk_* API to release the socket now. Otherwise go through the | 1417 | * inet layer to shut the socket down, and let userspace close it. |
1419 | * inet_* layer to shut the socket down, and let userspace close it. | 1418 | * Otherwise, if we created the socket directly within the kernel, use |
1419 | * the sk API to release it here. | ||
1420 | * In either case the tunnel resources are freed in the socket | 1420 | * In either case the tunnel resources are freed in the socket |
1421 | * destructor when the tunnel socket goes away. | 1421 | * destructor when the tunnel socket goes away. |
1422 | */ | 1422 | */ |
1423 | if (sock->file == NULL) { | 1423 | if (tunnel->fd >= 0) { |
1424 | kernel_sock_shutdown(sock, SHUT_RDWR); | 1424 | if (sock) |
1425 | sk_release_kernel(sk); | 1425 | inet_shutdown(sock, 2); |
1426 | } else { | 1426 | } else { |
1427 | inet_shutdown(sock, 2); | 1427 | if (sock) |
1428 | kernel_sock_shutdown(sock, SHUT_RDWR); | ||
1429 | sk_release_kernel(sk); | ||
1428 | } | 1430 | } |
1429 | 1431 | ||
1430 | l2tp_tunnel_sock_put(sk); | 1432 | l2tp_tunnel_sock_put(sk); |