On Sat, May 17, 2025 at 08:21:19PM -0700, Nicolin Chen wrote: > An object allocator needs to call either iommufd_object_finalize() upon a > success or iommufd_object_abort_and_destroy() upon an error code. > > To reduce duplication, store a new_obj in the struct iommufd_ucmd and call > iommufd_object_finalize/iommufd_object_abort_and_destroy() accordingly in > the main function. > > This will also ease a driver-allocated object so that a driver can simply > return with an error code to trigger an iommufd_object_abort_and_destroy() > instead of doing an abort itself. > > Similar to iommufd_object_alloc() and __iommufd_object_alloc(), add a pair > of helpers: __iommufd_object_alloc_ucmd() and iommufd_object_alloc_ucmd(). > > Suggested-by: Jason Gunthorpe <j...@nvidia.com> > Signed-off-by: Nicolin Chen <nicol...@nvidia.com> > --- > drivers/iommu/iommufd/iommufd_private.h | 1 + > include/linux/iommufd.h | 23 +++++++++++++++++++++++ > drivers/iommu/iommufd/driver.c | 18 ++++++++++++++++++ > drivers/iommu/iommufd/main.c | 7 +++++++ > 4 files changed, 49 insertions(+)
Reviewed-by: Jason Gunthorpe <j...@nvidia.com> Jason