summaryrefslogtreecommitdiffstats
path: root/samples/vfio-mdev
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2021-08-05 22:19:07 -0300
committerAlex Williamson <alex.williamson@redhat.com>2021-08-11 09:50:11 -0600
commit3cb24827147b75557bddc5b39d63897786935b14 (patch)
tree4b1dc7e88f644f777559fdc55f7c86ef0cc785b5 /samples/vfio-mdev
parentdb44c17458fb54880b9a65479e464b64c365a87d (diff)
downloadlinux-3cb24827147b75557bddc5b39d63897786935b14.tar.bz2
vfio/mbochs: Fix close when multiple device FDs are open
mbochs_close() iterates over global device state and frees it. Currently this is done every time a device FD is closed, but if multiple device FDs are open this could corrupt other still active FDs. Change this to use close_device() so it only runs on the last close. Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/11-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'samples/vfio-mdev')
-rw-r--r--samples/vfio-mdev/mbochs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index 7b2e12fe7082..c313ab4d1f4e 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -1278,7 +1278,7 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd,
return -ENOTTY;
}
-static void mbochs_close(struct vfio_device *vdev)
+static void mbochs_close_device(struct vfio_device *vdev)
{
struct mdev_state *mdev_state =
container_of(vdev, struct mdev_state, vdev);
@@ -1396,7 +1396,7 @@ static struct attribute_group *mdev_type_groups[] = {
};
static const struct vfio_device_ops mbochs_dev_ops = {
- .release = mbochs_close,
+ .close_device = mbochs_close_device,
.read = mbochs_read,
.write = mbochs_write,
.ioctl = mbochs_ioctl,