[PATCH rc 1/3] iommufd/selftest: Do not try to destroy an access once it is attached

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The access must be detached first.

To make the cleanup simpler copy the fdno to userspace before creating the
access in the first place. Then there is no need to unwind after
iommufd_access_attach.

Fixes: 54b47585db66 ("iommufd: Create access in vfio_iommufd_emulated_bind()")
Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
---
 drivers/iommu/iommufd/selftest.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index 74c2076105d486..65c8b6ad2504f0 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -716,6 +716,10 @@ static int iommufd_test_create_access(struct iommufd_ucmd *ucmd,
 		rc = -ENOMEM;
 		goto out_free_staccess;
 	}
+	cmd->create_access.out_access_fd = fdno;
+	rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));
+	if (rc)
+		goto out_put_fdno;
 
 	access = iommufd_access_create(
 		ucmd->ictx,
@@ -727,11 +731,8 @@ static int iommufd_test_create_access(struct iommufd_ucmd *ucmd,
 		rc = PTR_ERR(access);
 		goto out_put_fdno;
 	}
+
 	rc = iommufd_access_attach(access, ioas_id);
-	if (rc)
-		goto out_destroy;
-	cmd->create_access.out_access_fd = fdno;
-	rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));
 	if (rc)
 		goto out_destroy;
 
-- 
2.41.0




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux