iommu: Flow ERR_PTR out from __iommu_domain_alloc()
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 1 Nov 2023 23:28:11 +0000 (20:28 -0300)
committerJoerg Roedel <jroedel@suse.de>
Mon, 27 Nov 2023 09:33:25 +0000 (10:33 +0100)
commit34e2dccbb30baf7e5502bae382722aacbbfddc5b
treef2858c93d8f8ddec35ae3449cea7950a38260244
parent2cc14f52aeb78ce3f29677c2de1f06c0e91471ab
iommu: Flow ERR_PTR out from __iommu_domain_alloc()

Most of the calling code now has error handling that can carry an error
code further up the call chain. Keep the exported interface
iommu_domain_alloc() returning NULL and reflow the internal code to use
ERR_PTR not NULL for domain allocation failure.

Optionally allow drivers to return ERR_PTR from any of the alloc ops. Many
of the new ops (user, sva, etc) already return ERR_PTR, so having two
rules is confusing and hard on drivers. This fixes a bug in DART that was
returning ERR_PTR.

Fixes: 482feb5c6492 ("iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging()")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/linux-iommu/b85e0715-3224-4f45-ad6b-ebb9f08c015d@moroto.mountain/
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Link: https://lore.kernel.org/r/0-v2-55ae413017b8+97-domain_alloc_err_ptr_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c