summaryrefslogtreecommitdiff
path: root/net/nfc/llcp_sock.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-05-03 18:29:30 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-14 13:45:07 +0200
commitb4011239a08e7e6c2c6e970dfa9e8ecb73139261 (patch)
treebdb25a99be7021b952d387b9b2a264741aae0e94 /net/nfc/llcp_sock.c
parent7cbe0ff3e475b7268ad9b55057048b2299fd60e0 (diff)
downloadlwn-b4011239a08e7e6c2c6e970dfa9e8ecb73139261.tar.gz
lwn-b4011239a08e7e6c2c6e970dfa9e8ecb73139261.zip
NFC: llcp: Fix non blocking sockets connections
Without the new LLCP_CONNECTING state, non blocking sockets will be woken up with a POLLHUP right after calling connect() because their state is stuck at LLCP_CLOSED. That prevents userspace from implementing any proper non blocking socket based NFC p2p client. Cc: stable@vger.kernel.org Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc/llcp_sock.c')
-rw-r--r--net/nfc/llcp_sock.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 47e7acfc0236..d308402b67d8 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -571,7 +571,7 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= POLLHUP;
- if (sock_writeable(sk))
+ if (sock_writeable(sk) && sk->sk_state == LLCP_CONNECTED)
mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
@@ -729,14 +729,16 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
if (ret)
goto sock_unlink;
+ sk->sk_state = LLCP_CONNECTING;
+
ret = sock_wait_state(sk, LLCP_CONNECTED,
sock_sndtimeo(sk, flags & O_NONBLOCK));
- if (ret)
+ if (ret && ret != -EINPROGRESS)
goto sock_unlink;
release_sock(sk);
- return 0;
+ return ret;
sock_unlink:
nfc_llcp_put_ssap(local, llcp_sock->ssap);