]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/vmw_vsock/hyperv_transport.c
hv_sock: Fix hang when a connection is closed
[mirror_ubuntu-bionic-kernel.git] / net / vmw_vsock / hyperv_transport.c
index 9c7da811d130f84800567ed13bb89ba0af4481b4..98f193fd5315e7d878a3dd1de3cd4a1ec9410a29 100644 (file)
@@ -320,6 +320,11 @@ static void hvs_close_connection(struct vmbus_channel *chan)
        lock_sock(sk);
        hvs_do_close_lock_held(vsock_sk(sk), true);
        release_sock(sk);
+
+       /* Release the refcnt for the channel that's opened in
+        * hvs_open_connection().
+        */
+       sock_put(sk);
 }
 
 static void hvs_open_connection(struct vmbus_channel *chan)
@@ -388,6 +393,9 @@ static void hvs_open_connection(struct vmbus_channel *chan)
        }
 
        set_per_channel_state(chan, conn_from_host ? new : sk);
+
+       /* This reference will be dropped by hvs_close_connection(). */
+       sock_hold(conn_from_host ? new : sk);
        vmbus_set_chn_rescind_callback(chan, hvs_close_connection);
 
        /* Set the pending send size to max packet size to always get