vsock: prevent unnecessary refcnt inc for nonblocking connect
stable inclusion from stable-5.10.80 commit 7e03b797bee0b9da2d329c3edbc6937062f01215 bugzilla: 185821 https://gitee.com/openeuler/kernel/issues/I4L7CG Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7e03b797bee0b9da2d329c3edbc6937062f01215 -------------------------------- [ Upstream commit c7cd82b9 ] 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: d021c344 ("VSOCK: Introduce VM Sockets") Reviewed-by: NStefano Garzarella <sgarzare@redhat.com> Signed-off-by: NEiichi Tsukata <eiichi.tsukata@nutanix.com> Signed-off-by: NDavid S. Miller <davem@davemloft.net> Signed-off-by: NSasha Levin <sashal@kernel.org> Signed-off-by: NChen Jun <chenjun102@huawei.com> Reviewed-by: NWeilong Chen <chenweilong@huawei.com> Acked-by: NWeilong Chen <chenweilong@huawei.com> Signed-off-by: NChen Jun <chenjun102@huawei.com> Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Showing
想要评论请 注册 或 登录