Skip to content

Commit 1765b90

Browse files
siddhpantNipaLocal
authored andcommitted
nfc: Do not send datagram if socket state isn't LLCP_BOUND
As we know we cannot send the datagram (state can be set to LLCP_CLOSED by nfc_llcp_socket_release()), there is no need to proceed further. Thus, bail out early from llcp_sock_sendmsg(). Signed-off-by: Siddh Raman Pant <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Suman Ghosh <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent f47e650 commit 1765b90

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/nfc/llcp_sock.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,11 @@ static int llcp_sock_sendmsg(struct socket *sock, struct msghdr *msg,
796796
}
797797

798798
if (sk->sk_type == SOCK_DGRAM) {
799+
if (sk->sk_state != LLCP_BOUND) {
800+
release_sock(sk);
801+
return -ENOTCONN;
802+
}
803+
799804
DECLARE_SOCKADDR(struct sockaddr_nfc_llcp *, addr,
800805
msg->msg_name);
801806

0 commit comments

Comments
 (0)