--- x/drivers/vhost/vsock.c +++ y/drivers/vhost/vsock.c @@ -55,6 +55,7 @@ struct vhost_vsock { struct list_head send_pkt_list; /* host->guest pending packets */ atomic_t queued_replies; + int cleanup; u32 guest_cid; bool seqpacket_allow; @@ -262,6 +263,9 @@ vhost_transport_do_send_pkt(struct vhost out: mutex_unlock(&vq->mutex); + if (vsock->cleanup) + return; + if (restart_tx) vhost_poll_queue(&tx_vq->poll); } @@ -501,6 +505,9 @@ static void vhost_vsock_handle_tx_kick(s unsigned int out, in; bool added = false; + if (vsock->cleanup) + if (test_and_set_bit(VHOST_WORK_QUEUED, &work->flags)) + return; mutex_lock(&vq->mutex); if (!vhost_vq_get_backend(vq)) @@ -678,6 +685,7 @@ static int vhost_vsock_dev_open(struct i } vsock->guest_cid = 0; /* no CID assigned yet */ + vsock->cleanup = 0; atomic_set(&vsock->queued_replies, 0); @@ -741,6 +749,7 @@ static int vhost_vsock_dev_release(struc { struct vhost_vsock *vsock = file->private_data; + vsock->cleanup = 1; mutex_lock(&vhost_vsock_mutex); if (vsock->guest_cid) hash_del_rcu(&vsock->hash);