Commit 55f3e149 authored by Stefano Garzarella's avatar Stefano Garzarella Committed by David S. Miller

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: default avatarDexuan Cui <decui@microsoft.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: default avatarJorgen Hansen <jhansen@vmware.com>
Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b9ca2f5f
...@@ -634,9 +634,6 @@ static struct sock *__vsock_create(struct net *net, ...@@ -634,9 +634,6 @@ static struct sock *__vsock_create(struct net *net,
return NULL; return NULL;
} }
if (sock)
vsock_insert_unbound(vsk);
return sk; return sk;
} }
...@@ -1887,6 +1884,8 @@ static const struct proto_ops vsock_stream_ops = { ...@@ -1887,6 +1884,8 @@ static const struct proto_ops vsock_stream_ops = {
static int vsock_create(struct net *net, struct socket *sock, static int vsock_create(struct net *net, struct socket *sock,
int protocol, int kern) int protocol, int kern)
{ {
struct sock *sk;
if (!sock) if (!sock)
return -EINVAL; return -EINVAL;
...@@ -1906,7 +1905,13 @@ static int vsock_create(struct net *net, struct socket *sock, ...@@ -1906,7 +1905,13 @@ static int vsock_create(struct net *net, struct socket *sock,
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
return __vsock_create(net, sock, NULL, GFP_KERNEL, 0, kern) ? 0 : -ENOMEM; sk = __vsock_create(net, sock, NULL, GFP_KERNEL, 0, kern);
if (!sk)
return -ENOMEM;
vsock_insert_unbound(vsock_sk(sk));
return 0;
} }
static const struct net_proto_family vsock_family_ops = { static const struct net_proto_family vsock_family_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment