l2tp: don't BUG_ON sk_socket being NULL
It is valid for an existing struct sock object to have a NULL sk_socket pointer, so don't BUG_ON in l2tp_tunnel_del_work if that should occur. Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: James Chapman <jchapman@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8abbbe8ff5
commit
02d13ed5f9
@ -1412,19 +1412,21 @@ static void l2tp_tunnel_del_work(struct work_struct *work)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
sock = sk->sk_socket;
|
sock = sk->sk_socket;
|
||||||
BUG_ON(!sock);
|
|
||||||
|
|
||||||
/* If the tunnel socket was created directly by the kernel, use the
|
/* If the tunnel socket was created by userspace, then go through the
|
||||||
* sk_* API to release the socket now. Otherwise go through the
|
* inet layer to shut the socket down, and let userspace close it.
|
||||||
* inet_* layer to shut the socket down, and let userspace close it.
|
* Otherwise, if we created the socket directly within the kernel, use
|
||||||
|
* the sk API to release it here.
|
||||||
* In either case the tunnel resources are freed in the socket
|
* In either case the tunnel resources are freed in the socket
|
||||||
* destructor when the tunnel socket goes away.
|
* destructor when the tunnel socket goes away.
|
||||||
*/
|
*/
|
||||||
if (sock->file == NULL) {
|
if (tunnel->fd >= 0) {
|
||||||
kernel_sock_shutdown(sock, SHUT_RDWR);
|
if (sock)
|
||||||
sk_release_kernel(sk);
|
inet_shutdown(sock, 2);
|
||||||
} else {
|
} else {
|
||||||
inet_shutdown(sock, 2);
|
if (sock)
|
||||||
|
kernel_sock_shutdown(sock, SHUT_RDWR);
|
||||||
|
sk_release_kernel(sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
l2tp_tunnel_sock_put(sk);
|
l2tp_tunnel_sock_put(sk);
|
||||||
|
Loading…
Reference in New Issue
Block a user