aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet
diff options
context:
space:
mode:
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>2011-02-24 18:14:56 -0500
committerDavid S. Miller <davem@davemloft.net>2011-02-25 14:19:34 -0500
commit96241544ca34721d601925850868188d6304cc0f (patch)
tree06d993f48b1e1198d6757f36a865e57415df09ec /net/phonet
parentb08cd667c4b6641c4d16a3f87f4550f81a6d69ac (diff)
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)
428 struct sock *sk = sock->sk; 428 struct sock *sk = sock->sk;
429 int err = 0; 429 int err = 0;
430 430
431 if (sock->state != SS_UNCONNECTED)
432 return -EINVAL;
433 if (pn_socket_autobind(sock)) 431 if (pn_socket_autobind(sock))
434 return -ENOBUFS; 432 return -ENOBUFS;
435 433
436 lock_sock(sk); 434 lock_sock(sk);
437 if (sk->sk_state != TCP_CLOSE) { 435 if (sock->state != SS_UNCONNECTED) {
438 err = -EINVAL; 436 err = -EINVAL;
439 goto out; 437 goto out;
440 } 438 }
441 439
442 sk->sk_state = TCP_LISTEN; 440 if (sk->sk_state != TCP_LISTEN) {
443 sk->sk_ack_backlog = 0; 441 sk->sk_state = TCP_LISTEN;
442 sk->sk_ack_backlog = 0;
443 }
444 sk->sk_max_ack_backlog = backlog; 444 sk->sk_max_ack_backlog = backlog;
445out: 445out:
446 release_sock(sk); 446 release_sock(sk);