Commit 2682d4e
Alex Williamson
vfio: Fix container device registration life cycle
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2155664
Conflicts: Semaphore vs mutex context since we don't yet include
c82e81a ("vfio: Change vfio_group->group_rwsem to a mutex")
commit 7fdba00
Author: Anthony DeRossi <ajderossi@gmail.com>
Date: Wed Nov 9 17:40:25 2022 -0800
vfio: Fix container device registration life cycle
In vfio_device_open(), vfio_device_container_register() is always called
when open_count == 1. On error, vfio_device_container_unregister() is
only called when open_count == 1 and close_device is set. This leaks a
registration for devices without a close_device implementation.
In vfio_device_fops_release(), vfio_device_container_unregister() is
called unconditionally. This can cause a device to be unregistered
multiple times.
Treating container device registration/unregistration uniformly (always
when open_count == 1) fixes both issues.
Fixes: ce4b465 ("vfio: Replace the DMA unmapping notifier with a callback")
Signed-off-by: Anthony DeRossi <ajderossi@gmail.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20221110014027.28780-2-ajderossi@gmail.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>1 parent 9a57ba0 commit 2682d4e
1 file changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1172 | 1172 | | |
1173 | 1173 | | |
1174 | 1174 | | |
1175 | | - | |
1176 | | - | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
1177 | 1178 | | |
1178 | 1179 | | |
1179 | 1180 | | |
| |||
1375 | 1376 | | |
1376 | 1377 | | |
1377 | 1378 | | |
1378 | | - | |
1379 | | - | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
1380 | 1382 | | |
1381 | | - | |
| 1383 | + | |
| 1384 | + | |
1382 | 1385 | | |
1383 | 1386 | | |
1384 | 1387 | | |
| |||
0 commit comments