vsock/virtio: fix flush of works during the .remove()
authorStefano Garzarella <sgarzare@redhat.com>
Fri, 28 Jun 2019 12:36:59 +0000 (14:36 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jul 2019 02:09:07 +0000 (19:09 -0700)
commit0d20e56ecca0f5025f9041d11ee247129b5e48ce
tree8bc5871ecca3409ab4de4e17fd9b481a2f965705
parent17dd1367389cfe7f150790c83247b68e0c19d106
vsock/virtio: fix flush of works during the .remove()

This patch moves the flush of works after vdev->config->del_vqs(vdev),
because we need to be sure that no workers run before to free the
'vsock' object.

Since we stopped the workers using the [tx|rx|event]_run flags,
we are sure no one is accessing the device while we are calling
vdev->config->reset(vdev), so we can safely move the workers' flush.

Before the vdev->config->del_vqs(vdev), workers can be scheduled
by VQ callbacks, so we must flush them after del_vqs(), to avoid
use-after-free of 'vsock' object.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/vmw_vsock/virtio_transport.c