]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
vfio: Remove device debugfs before releasing devres
authorAlex Williamson <alex.williamson@nvidia.com>
Mon, 15 Jun 2026 20:47:00 +0000 (14:47 -0600)
committerAlex Williamson <alex@shazbot.org>
Mon, 29 Jun 2026 20:26:28 +0000 (14:26 -0600)
commitdc7fe87de492ea7f33a72b78d26650b75bf37f4f
tree89b5d06d02ba93d4462ed0fd12e58f142e8813cd
parent3788cd493e444742bc2ba252eb5c09ffc8b345dc
vfio: Remove device debugfs before releasing devres

VFIO device debugfs files created with debugfs_create_devm_seqfile()
store a devres allocated debugfs_devm_entry as inode private data.
vfio_unregister_group_dev() currently calls vfio_device_del() before
vfio_device_debugfs_exit(), but device_del() releases devres.  This can
leave debugfs entries visible with stale inode private data while
unregister waits for userspace references to drain.

Remove the per-device debugfs tree before vfio_device_del().  The debugfs
view is diagnostic only, so losing it at the start of unregister is
preferable to preserving entries whose backing storage may already have
been released.

Complete the teardown by clearing the per-device debugfs root after
removal.  This matches the global debugfs root cleanup and prevents
future users from mistaking a removed dentry for a live debugfs tree
during the remainder of unregister.

Fixes: 2202844e4468 ("vfio/migration: Add debugfs to live migration driver")
Reported-by: Sashiko AI Review <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/r/20260615192725.6A2221F000E9@smtp.kernel.org
Cc: stable@vger.kernel.org
Cc: Longfang Liu <liulongfang@huawei.com>
Assisted-by: OpenAI Codex:gpt-5
Signed-off-by: Alex Williamson <alex.williamson@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20260615204717.735302-1-alex.williamson@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
drivers/vfio/debugfs.c
drivers/vfio/vfio_main.c