]> git.baikalelectronics.ru Git - kernel.git/commit
vhost-vdpa: call vhost_vdpa_cleanup during the release
authorStefano Garzarella <sgarzare@redhat.com>
Wed, 22 Jun 2022 15:14:07 +0000 (17:14 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 27 Jun 2022 12:05:35 +0000 (08:05 -0400)
commit9f4cf53062411229d8c065dd72c50c181825c705
tree919ee4726f1a48e71115e85381a47521dcfe8f20
parentc57bd9547d1437b592a3d54f0c3ea3cf49bc9083
vhost-vdpa: call vhost_vdpa_cleanup during the release

Before commit 15b71346f456 ("vhost-vdpa: introduce asid based IOTLB")
we call vhost_vdpa_iotlb_free() during the release to clean all regions
mapped in the iotlb.

That commit removed vhost_vdpa_iotlb_free() and added vhost_vdpa_cleanup()
to do some cleanup, including deleting all mappings, but we forgot to call
it in vhost_vdpa_release().

This causes that if an application does not remove all mappings explicitly
(or it crashes), the mappings remain in the iotlb and subsequent
applications may fail if they map the same addresses.

Calling vhost_vdpa_cleanup() also fixes a memory leak since we are not
freeing `v->vdev.vqs` during the release from the same commit.

Since vhost_vdpa_cleanup() calls vhost_dev_cleanup() we can remove its
call from vhost_vdpa_release().

Fixes: 15b71346f456 ("vhost-vdpa: introduce asid based IOTLB")
Cc: gautam.dawar@xilinx.com
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20220622151407.51232-1-sgarzare@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Eugenio PĂ©rez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/vhost/vdpa.c