vsock/virtio: fix flush of works during the .remove()
authorStefano Garzarella <sgarzare@redhat.com>
Fri, 5 Jul 2019 11:04:54 +0000 (13:04 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Jul 2019 22:35:17 +0000 (15:35 -0700)
commite226121fcc26e69c721a435aa9348a2f452e4d3e
tree0ef74aa77ece3c192dfef9cf8a251e12ddf8a63d
parentb917507e5ad983085d29069369778b16aa03a0a8
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