Skip to content

Commit 9b0d6b7

Browse files
jgunthorpeAlex Williamson
authored andcommitted
vfio/ap,ccw: Fix open/close when multiple device FDs are open
The user can open multiple device FDs if it likes, however these open() functions call vfio_register_notifier() on some device global state. Calling vfio_register_notifier() twice in will trigger a WARN_ON from notifier_chain_register() and the first close will wrongly delete the notifier and more. Since these really want the new open/close_device() semantics just change the functions over. Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/12-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 3cb2482 commit 9b0d6b7

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

drivers/s390/cio/vfio_ccw_ops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev)
159159
return 0;
160160
}
161161

162-
static int vfio_ccw_mdev_open(struct mdev_device *mdev)
162+
static int vfio_ccw_mdev_open_device(struct mdev_device *mdev)
163163
{
164164
struct vfio_ccw_private *private =
165165
dev_get_drvdata(mdev_parent_dev(mdev));
@@ -194,7 +194,7 @@ static int vfio_ccw_mdev_open(struct mdev_device *mdev)
194194
return ret;
195195
}
196196

197-
static void vfio_ccw_mdev_release(struct mdev_device *mdev)
197+
static void vfio_ccw_mdev_close_device(struct mdev_device *mdev)
198198
{
199199
struct vfio_ccw_private *private =
200200
dev_get_drvdata(mdev_parent_dev(mdev));
@@ -638,8 +638,8 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
638638
.supported_type_groups = mdev_type_groups,
639639
.create = vfio_ccw_mdev_create,
640640
.remove = vfio_ccw_mdev_remove,
641-
.open = vfio_ccw_mdev_open,
642-
.release = vfio_ccw_mdev_release,
641+
.open_device = vfio_ccw_mdev_open_device,
642+
.close_device = vfio_ccw_mdev_close_device,
643643
.read = vfio_ccw_mdev_read,
644644
.write = vfio_ccw_mdev_write,
645645
.ioctl = vfio_ccw_mdev_ioctl,

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev)
13151315
return rc;
13161316
}
13171317

1318-
static int vfio_ap_mdev_open(struct mdev_device *mdev)
1318+
static int vfio_ap_mdev_open_device(struct mdev_device *mdev)
13191319
{
13201320
struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev);
13211321
unsigned long events;
@@ -1348,7 +1348,7 @@ static int vfio_ap_mdev_open(struct mdev_device *mdev)
13481348
return ret;
13491349
}
13501350

1351-
static void vfio_ap_mdev_release(struct mdev_device *mdev)
1351+
static void vfio_ap_mdev_close_device(struct mdev_device *mdev)
13521352
{
13531353
struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev);
13541354

@@ -1427,8 +1427,8 @@ static const struct mdev_parent_ops vfio_ap_matrix_ops = {
14271427
.mdev_attr_groups = vfio_ap_mdev_attr_groups,
14281428
.create = vfio_ap_mdev_create,
14291429
.remove = vfio_ap_mdev_remove,
1430-
.open = vfio_ap_mdev_open,
1431-
.release = vfio_ap_mdev_release,
1430+
.open_device = vfio_ap_mdev_open_device,
1431+
.close_device = vfio_ap_mdev_close_device,
14321432
.ioctl = vfio_ap_mdev_ioctl,
14331433
};
14341434

0 commit comments

Comments
 (0)