Message ID | 0490c52b68c27730d9916ff22c917b4838c32af4.1702925869.git.code@siddh.me (mailing list archive) |
---|---|
State | Accepted |
Commit | 6ec0d7527c4287369b52df3bcefd21a0c4fb2b7c |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | nfc: Fix UAF during datagram sending caused by missing refcounting | expand |
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 645677f84dba..819157bbb5a2 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -796,6 +796,11 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg, } if (sk->sk_type == SOCK_DGRAM) { + if (sk->sk_state != LLCP_BOUND) { + release_sock(sk); + return -ENOTCONN; + } + DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr, msg->msg_name);