s390/vfio-ap: clean up mdev resources when remove callback invoked
authorTony Krowiak <akrowiak@linux.ibm.com>
Wed, 9 Jun 2021 22:46:32 +0000 (18:46 -0400)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 21 Jun 2021 09:19:18 +0000 (11:19 +0200)
commit8c0795d2a0f50e2b131f5b2a8c2795939a94058e
tree46dec4cc07c8753010cea30a6c83b94564b2134e
parentca1f4d702d534387aa1f16379edb3b03cdb6ceda
s390/vfio-ap: clean up mdev resources when remove callback invoked

The mdev remove callback for the vfio_ap device driver bails out with
-EBUSY if the mdev is in use by a KVM guest (i.e., the KVM pointer in the
struct ap_matrix_mdev is not NULL). The intended purpose was
to prevent the mdev from being removed while in use. There are two
problems with this scenario:

1. Returning a non-zero return code from the remove callback does not
   prevent the removal of the mdev.

2. The KVM pointer in the struct ap_matrix_mdev will always be NULL because
   the remove callback will not get invoked until the mdev fd is closed.
   When the mdev fd is closed, the mdev release callback is invoked and
   clears the KVM pointer from the struct ap_matrix_mdev.

Let's go ahead and remove the check for KVM in the remove callback and
allow the cleanup of mdev resources to proceed.

Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20210609224634.575156-2-akrowiak@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/crypto/vfio_ap_ops.c