[Intel-gfx] [PATCH v4] vfio: fix potential deadlock on vfio group lock

Tian, Kevin kevin.tian at intel.com
Tue Jan 17 09:05:40 UTC 2023


> From: Matthew Rosato <mjrosato at linux.ibm.com>
> Sent: Saturday, January 14, 2023 8:04 AM
>
>  void vfio_device_group_close(struct vfio_device *device)
>  {
> +	void (*put_kvm)(struct kvm *kvm);
> +	struct kvm *kvm;
> +
>  	mutex_lock(&device->group->group_lock);
> +	kvm = device->kvm;
> +	put_kvm = device->put_kvm;
>  	vfio_device_close(device, device->group->iommufd);
> +	if (kvm == device->kvm)
> +		kvm = NULL;

Add a simple comment that this check is to detect the last close

> +void vfio_kvm_put_kvm(void (*put)(struct kvm *kvm), struct kvm *kvm)
> +{
> +	if (WARN_ON(!put))
> +		return;

also WARN_ON(!kvm)?

otherwise this looks good to me:

Reviewed-by: Kevin Tian <kevin.tian at intel.com>


More information about the Intel-gfx mailing list