Skip to content

Commit 55f3e14

Browse files
stefano-garzarelladavem330
authored andcommitted
vsock: move vsock_insert_unbound() in the vsock_create()
vsock_insert_unbound() was called only when 'sock' parameter of __vsock_create() was not null. This only happened when __vsock_create() was called by vsock_create(). In order to simplify the multi-transports support, this patch moves vsock_insert_unbound() at the end of vsock_create(). Reviewed-by: Dexuan Cui <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Jorgen Hansen <[email protected]> Signed-off-by: Stefano Garzarella <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b9ca2f5 commit 55f3e14

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,6 @@ static struct sock *__vsock_create(struct net *net,
634634
return NULL;
635635
}
636636

637-
if (sock)
638-
vsock_insert_unbound(vsk);
639-
640637
return sk;
641638
}
642639

@@ -1887,6 +1884,8 @@ static const struct proto_ops vsock_stream_ops = {
18871884
static int vsock_create(struct net *net, struct socket *sock,
18881885
int protocol, int kern)
18891886
{
1887+
struct sock *sk;
1888+
18901889
if (!sock)
18911890
return -EINVAL;
18921891

@@ -1906,7 +1905,13 @@ static int vsock_create(struct net *net, struct socket *sock,
19061905

19071906
sock->state = SS_UNCONNECTED;
19081907

1909-
return __vsock_create(net, sock, NULL, GFP_KERNEL, 0, kern) ? 0 : -ENOMEM;
1908+
sk = __vsock_create(net, sock, NULL, GFP_KERNEL, 0, kern);
1909+
if (!sk)
1910+
return -ENOMEM;
1911+
1912+
vsock_insert_unbound(vsock_sk(sk));
1913+
1914+
return 0;
19101915
}
19111916

19121917
static const struct net_proto_family vsock_family_ops = {

0 commit comments

Comments
 (0)