mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 22:25:03 +00:00
vsock: prevent unnecessary refcnt inc for nonblocking connect
[ Upstream commitc7cd82b905
] Currently vosck_connect() increments sock refcount for nonblocking socket each time it's called, which can lead to memory leak if it's called multiple times because connect timeout function decrements sock refcount only once. Fixes it by making vsock_connect() return -EALREADY immediately when sock state is already SS_CONNECTING. Fixes:d021c34405
("VSOCK: Introduce VM Sockets") Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
72aca95f95
commit
b2d1b6624b
1 changed files with 2 additions and 0 deletions
|
@ -1151,6 +1151,8 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
|
||||||
* non-blocking call.
|
* non-blocking call.
|
||||||
*/
|
*/
|
||||||
err = -EALREADY;
|
err = -EALREADY;
|
||||||
|
if (flags & O_NONBLOCK)
|
||||||
|
goto out;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ((sk->sk_state == TCP_LISTEN) ||
|
if ((sk->sk_state == TCP_LISTEN) ||
|
||||||
|
|
Loading…
Reference in a new issue