These days drivers with state should use cdev_device_add() and cdev_device_del() to manage the cdev and sysfs lifetime. This simple pattern ties all the state (vfio, dev, and cdev) together in one memory structure and uses container_of() to navigate between the layers. This is a followup to the discussion here: https://lore.kernel.org/kvm/20210921155705.GN327412@xxxxxxxxxx/ This builds on Christoph's work to revise how the vfio_group works and is against the latest VFIO tree. Jason Gunthorpe (5): vfio: Delete vfio_get/put_group from vfio_iommu_group_notifier() vfio: Do not open code the group list search in vfio_create_group() vfio: Don't leak a group reference if the group already exists vfio: Use a refcount_t instead of a kref in the vfio_group vfio: Use cdev_device_add() instead of device_create() drivers/vfio/vfio.c | 363 +++++++++++++++++--------------------------- 1 file changed, 140 insertions(+), 223 deletions(-) base-commit: d9a0cd510c3383b61db6f70a84e0c3487f836a63 -- 2.33.0