Skip to content

Commit 6ec0d75

Browse files
siddhpantdavem330
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 <code@siddh.me> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Suman Ghosh <sumang@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c95f919 commit 6ec0d75

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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)