diff --git a/drivers/iommu/iommu-sva-lib.h b/drivers/iommu/iommu-sva-lib.hIs there a reason to use the 'safe' version of container_of()? Callers of
index 8909ea1094e3..1be21e6b93ec 100644
--- a/drivers/iommu/iommu-sva-lib.h
+++ b/drivers/iommu/iommu-sva-lib.h
@@ -7,6 +7,7 @@
#include <linux/ioasid.h>
#include <linux/mm_types.h>
+#include <linux/iommu.h>
int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max);
struct mm_struct *iommu_sva_find(ioasid_t pasid);
@@ -16,6 +17,20 @@ struct device;
struct iommu_fault;
struct iopf_queue;
+struct iommu_sva_domain {
+ struct iommu_domain domain;
+ struct mm_struct *mm;
+};
+
+#define to_sva_domain(d) container_of_safe(d, struct iommu_sva_domain, domain)
to_sva_domain() don't check the return value before dereferencing it so
they would break anyway if someone passes an error pointer as domain. I
think it matters because there is no other user of container_of_safe() in
the kernel (the only user, lustre, went away in 2018) so someone will want
to remove it.
Apart from that
Reviewed-by: Jean-Philippe Brucker<jean-philippe@xxxxxxxxxx>