Skip to content

Commit 96cbf89

Browse files
phi-nguyendpPaolo Abeni
authored andcommitted
vsock: use sock_error() to consume sk_err after a failed connect
vsock_connect() returns sk_err to userspace but does not clear it: if (sk->sk_err) { err = -sk->sk_err; For a blocking connect() the error has already been delivered as connect()'s return value, so leaving it set causes subsequent operations like poll()/epoll() to keep reporting POLLERR even though the connect failure was already delivered. The error should be consumed once it has been returned to userspace. Switch to sock_error(), which reads and clears sk_err atomically, matching the behavior of other protocol implementations such as __inet_stream_connect(). Fixes: d021c34 ("VSOCK: Introduce VM Sockets") Tested-by: Wupeng Ma <mawupeng1@huawei.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com> Link: https://patch.msgid.link/20260813173024.2362935-4-phind.uet@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 81fc0f3 commit 96cbf89

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

net/vmw_vsock/af_vsock.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,12 +1842,10 @@ static int vsock_connect(struct socket *sock, struct sockaddr_unsized *addr,
18421842
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
18431843
}
18441844

1845-
if (sk->sk_err) {
1846-
err = -sk->sk_err;
1845+
err = sock_error(sk);
1846+
if (err) {
18471847
sk->sk_state = TCP_CLOSE;
18481848
sock->state = SS_UNCONNECTED;
1849-
} else {
1850-
err = 0;
18511849
}
18521850

18531851
out_wait:

0 commit comments

Comments
 (0)