[PATCH v2 05/22] iommufd: Add iommufd_struct_destroy to revert iommufd_viommu_alloc

Nicolin Chen nicolinc at nvidia.com
Mon Apr 28 10:24:35 PDT 2025


On Sun, Apr 27, 2025 at 02:55:40PM +0800, Baolu Lu wrote:
> On 4/26/25 13:58, Nicolin Chen wrote:
> > An IOMMU driver that allocated a vIOMMU may want to revert the allocation,
> > if it encounters an internal error after the allocation. So, there needs a
> > destroy helper for drivers to use.
> 
> A brief explanation or a small code snippet illustrating a typical
> allocation and potential abort scenario would be helpful.

Will add the followings:

"
For instance:

static my_viommu_alloc()
{
	...
	my_viommu = iommufd_vcmdq_alloc(viomm, struct my_viommu, core);
	...
	ret = init_my_viommu();
	if (ret) {
		iommufd_struct_destroy(viommu->ictx, my_viommu, core);
		return ERR_PTR(ret);
	}
	return &my_viommu->core;
}
"

Thanks
Nicolin



More information about the linux-arm-kernel mailing list