diff options
Diffstat (limited to 'net/unix/af_unix.c')
| -rw-r--r-- | net/unix/af_unix.c | 26 | 
1 files changed, 18 insertions, 8 deletions
| diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 29be035f9c65..f75f847e688d 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1781,7 +1781,12 @@ restart_locked:  			goto out_unlock;  	} -	if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) { +	/* other == sk && unix_peer(other) != sk if +	 * - unix_peer(sk) == NULL, destination address bound to sk +	 * - unix_peer(sk) == sk by time of get but disconnected before lock +	 */ +	if (other != sk && +	    unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {  		if (timeo) {  			timeo = unix_wait_for_peer(other, timeo); @@ -2277,13 +2282,15 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)  	size_t size = state->size;  	unsigned int last_len; -	err = -EINVAL; -	if (sk->sk_state != TCP_ESTABLISHED) +	if (unlikely(sk->sk_state != TCP_ESTABLISHED)) { +		err = -EINVAL;  		goto out; +	} -	err = -EOPNOTSUPP; -	if (flags & MSG_OOB) +	if (unlikely(flags & MSG_OOB)) { +		err = -EOPNOTSUPP;  		goto out; +	}  	target = sock_rcvlowat(sk, flags & MSG_WAITALL, size);  	timeo = sock_rcvtimeo(sk, noblock); @@ -2305,6 +2312,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)  		bool drop_skb;  		struct sk_buff *skb, *last; +redo:  		unix_state_lock(sk);  		if (sock_flag(sk, SOCK_DEAD)) {  			err = -ECONNRESET; @@ -2329,9 +2337,11 @@ again:  				goto unlock;  			unix_state_unlock(sk); -			err = -EAGAIN; -			if (!timeo) +			if (!timeo) { +				err = -EAGAIN;  				break; +			} +  			mutex_unlock(&u->readlock);  			timeo = unix_stream_data_wait(sk, timeo, last, @@ -2344,7 +2354,7 @@ again:  			}  			mutex_lock(&u->readlock); -			continue; +			goto redo;  unlock:  			unix_state_unlock(sk);  			break; | 
