Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96241544 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont Committed by David S. Miller
Browse files

Phonet: allow multiple listen() and fix small race condition

parent b08cd667
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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;
	}

	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);