Skip to content

Commit

Permalink
Phonet: allow multiple listen() and fix small race condition
Browse files Browse the repository at this point in the history
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rémi Denis-Courmont authored and David S. Miller committed Feb 25, 2011
1 parent b08cd66 commit 9624154
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/phonet/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9624154

Please sign in to comment.