]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/vmw_vsock/af_vsock.c
Merge tag 'devicetree-fixes-for-5.6-3' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / net / vmw_vsock / af_vsock.c
index 9c5b2a91baad60945cd06881c57d1b0c56810a58..a5f28708e0e75402e595a38ee91c57e9637e0289 100644 (file)
@@ -451,6 +451,12 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk)
                if (vsk->transport == new_transport)
                        return 0;
 
+               /* transport->release() must be called with sock lock acquired.
+                * This path can only be taken during vsock_stream_connect(),
+                * where we have already held the sock lock.
+                * In the other cases, this function is called on a new socket
+                * which is not assigned to any transport.
+                */
                vsk->transport->release(vsk);
                vsock_deassign_transport(vsk);
        }
@@ -753,20 +759,18 @@ static void __vsock_release(struct sock *sk, int level)
                vsk = vsock_sk(sk);
                pending = NULL; /* Compiler warning. */
 
-               /* The release call is supposed to use lock_sock_nested()
-                * rather than lock_sock(), if a sock lock should be acquired.
-                */
-               if (vsk->transport)
-                       vsk->transport->release(vsk);
-               else if (sk->sk_type == SOCK_STREAM)
-                       vsock_remove_sock(vsk);
-
                /* When "level" is SINGLE_DEPTH_NESTING, use the nested
                 * version to avoid the warning "possible recursive locking
                 * detected". When "level" is 0, lock_sock_nested(sk, level)
                 * is the same as lock_sock(sk).
                 */
                lock_sock_nested(sk, level);
+
+               if (vsk->transport)
+                       vsk->transport->release(vsk);
+               else if (sk->sk_type == SOCK_STREAM)
+                       vsock_remove_sock(vsk);
+
                sock_orphan(sk);
                sk->sk_shutdown = SHUTDOWN_MASK;