Skip to content

Commit 8512ed2

Browse files
brettcreeleyawilliam
authored andcommitted
vfio/pds: Always clear the save/restore FDs on reset
After reset the VFIO device state will always be put in VFIO_DEVICE_STATE_RUNNING, but the save/restore files will only be cleared if the previous state was VFIO_DEVICE_STATE_ERROR. This can/will cause the restore/save files to be leaked if/when the migration state machine transitions through the states that re-allocates these files. Fix this by always clearing the restore/save files for resets. Fixes: 7dabb1b ("vfio/pds: Add support for firmware recovery") Cc: stable@vger.kernel.org Signed-off-by: Brett Creeley <brett.creeley@amd.com> Reviewed-by: Shannon Nelson <shannon.nelson@amd.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/20240228003205.47311-2-brett.creeley@amd.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 701ab93 commit 8512ed2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/vfio/pci/pds/vfio_dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ void pds_vfio_state_mutex_unlock(struct pds_vfio_pci_device *pds_vfio)
3232
mutex_lock(&pds_vfio->reset_mutex);
3333
if (pds_vfio->deferred_reset) {
3434
pds_vfio->deferred_reset = false;
35+
pds_vfio_put_restore_file(pds_vfio);
36+
pds_vfio_put_save_file(pds_vfio);
3537
if (pds_vfio->state == VFIO_DEVICE_STATE_ERROR) {
36-
pds_vfio_put_restore_file(pds_vfio);
37-
pds_vfio_put_save_file(pds_vfio);
3838
pds_vfio_dirty_disable(pds_vfio, false);
3939
}
4040
pds_vfio->state = pds_vfio->deferred_reset_state;

0 commit comments

Comments
 (0)