Commit 34c899af authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by Paolo Abeni
Browse files

af_unix: Set error only when needed in unix_stream_connect().



We will introduce skb drop reason for AF_UNIX, then we need to
set an errno and a drop reason for each path.

Let's set an error only when it's needed in unix_stream_connect().

Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent a14a4290
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -1575,12 +1575,12 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
		goto out;
	}

	err = -ENOMEM;

	/* Allocate skb for sending to listening sock */
	skb = sock_wmalloc(newsk, 1, 0, GFP_KERNEL);
	if (skb == NULL)
	if (!skb) {
		err = -ENOMEM;
		goto out;
	}

restart:
	/*  Find listening sock. */
@@ -1600,16 +1600,17 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
		goto restart;
	}

	if (other->sk_state != TCP_LISTEN ||
	    other->sk_shutdown & RCV_SHUTDOWN) {
		err = -ECONNREFUSED;
	if (other->sk_state != TCP_LISTEN)
		goto out_unlock;
	if (other->sk_shutdown & RCV_SHUTDOWN)
		goto out_unlock;
	}

	if (unix_recvq_full_lockless(other)) {
		if (!timeo) {
			err = -EAGAIN;
		if (!timeo)
			goto out_unlock;
		}

		timeo = unix_wait_for_peer(other, timeo);