summaryrefslogtreecommitdiffstats
path: root/net/phonet
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>2011-02-24 23:14:56 +0000
committerDavid S. Miller <davem@davemloft.net>2011-02-25 11:19:34 -0800
commit96241544ca34721d601925850868188d6304cc0f (patch)
tree06d993f48b1e1198d6757f36a865e57415df09ec /net/phonet
parentb08cd667c4b6641c4d16a3f87f4550f81a6d69ac (diff)
downloadlinux-96241544ca34721d601925850868188d6304cc0f.tar.gz
linux-96241544ca34721d601925850868188d6304cc0f.tar.bz2
linux-96241544ca34721d601925850868188d6304cc0f.zip
Phonet: allow multiple listen() and fix small race condition
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/phonet')
-rw-r--r--net/phonet/socket.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 25f746d20c1f..ceb5143f5ef9 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -428,19 +428,19 @@ static int pn_socket_listen(struct socket *sock, int backlog)
struct sock *sk = sock->sk;
int err = 0;
- if (sock->state != SS_UNCONNECTED)
- return -EINVAL;
if (pn_socket_autobind(sock))
return -ENOBUFS;
lock_sock(sk);
- if (sk->sk_state != TCP_CLOSE) {
+ if (sock->state != SS_UNCONNECTED) {
err = -EINVAL;
goto out;
}
- sk->sk_state = TCP_LISTEN;
- sk->sk_ack_backlog = 0;
+ if (sk->sk_state != TCP_LISTEN) {
+ sk->sk_state = TCP_LISTEN;
+ sk->sk_ack_backlog = 0;
+ }
sk->sk_max_ack_backlog = backlog;
out:
release_sock(sk);