On Fri, Nov 04, 2022 at 02:59:15PM -0600, Alex Williamson wrote: > On Fri, 4 Nov 2022 12:57:25 -0700 > Anthony DeRossi <ajderossi@xxxxxxxxx> wrote: > > > In vfio_device_open(), vfio_container_device_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. > > Good catch, I see that Jason does subtly fix this in "vfio: Move > vfio_device driver open/close code to a function", but I'd rather see > it more overtly fixed in a discrete patch like this. All "real" > drivers provide a close_device callback, but mdpy and mtty do not. Given it only impacts the samples maybe I should just stick it in the iommufd series before that patch? Jason