Skip to content

Commit 3cb2482

Browse files
jgunthorpeAlex Williamson
authored andcommitted
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>
1 parent db44c17 commit 3cb2482

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

samples/vfio-mdev/mbochs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd,
12781278
return -ENOTTY;
12791279
}
12801280

1281-
static void mbochs_close(struct vfio_device *vdev)
1281+
static void mbochs_close_device(struct vfio_device *vdev)
12821282
{
12831283
struct mdev_state *mdev_state =
12841284
container_of(vdev, struct mdev_state, vdev);
@@ -1396,7 +1396,7 @@ static struct attribute_group *mdev_type_groups[] = {
13961396
};
13971397

13981398
static const struct vfio_device_ops mbochs_dev_ops = {
1399-
.release = mbochs_close,
1399+
.close_device = mbochs_close_device,
14001400
.read = mbochs_read,
14011401
.write = mbochs_write,
14021402
.ioctl = mbochs_ioctl,

0 commit comments

Comments
 (0)