Skip to content
Commit 7fdba001 authored by Anthony DeRossi's avatar Anthony DeRossi Committed by Alex Williamson
Browse files

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: ce4b4657 ("vfio: Replace the DMA unmapping notifier with a callback")
Signed-off-by: default avatarAnthony DeRossi <ajderossi@gmail.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Reviewed-by: default avatarYi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20221110014027.28780-2-ajderossi@gmail.com


Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent f0c4d9fc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment