--- x/drivers/iommu/iommufd/selftest.c +++ y/drivers/iommu/iommufd/selftest.c @@ -393,7 +393,8 @@ err_put: static void mock_dev_destroy(struct mock_dev *mdev) { - iommu_group_remove_device(&mdev->dev); + if (mdev->dev.iommu->iommu_dev != &mock_iommu_device) + iommu_group_remove_device(&mdev->dev); device_del(&mdev->dev); kfree(mdev->dev.iommu); mdev->dev.iommu = NULL;