From: Rémi Denis-Courmont Date: Thu, 24 Feb 2011 23:14:56 +0000 (+0000) Subject: Phonet: allow multiple listen() and fix small race condition X-Git-Tag: v2.6.39-rc1~468^2~235 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=96241544ca34721d601925850868188d6304cc0f;p=platform%2Fkernel%2Flinux-stable.git Phonet: allow multiple listen() and fix small race condition Signed-off-by: Rémi Denis-Courmont Signed-off-by: David S. Miller --- diff --git a/net/phonet/socket.c b/net/phonet/socket.c index 25f746d..ceb5143 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);