Message ID | 20210821035045.373991-1-jiang.wang@bytedance.com |
---|---|
State | New |
Headers | show |
Series | [v1] af_unix: fix NULL pointer bug in unix_shutdown | expand |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 443c49081636..6965bc578a80 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2847,7 +2847,8 @@ static int unix_shutdown(struct socket *sock, int mode) int peer_mode = 0; const struct proto *prot = READ_ONCE(other->sk_prot); - prot->unhash(other); + if (sk->sk_type == SOCK_STREAM) + prot->unhash(other); if (mode&RCV_SHUTDOWN) peer_mode |= SEND_SHUTDOWN; if (mode&SEND_SHUTDOWN)