iommu/arm-smmu-v3: Fix a NULL vs IS_ERR() check
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 15 Aug 2024 11:25:00 +0000 (14:25 +0300)
committerWill Deacon <will@kernel.org>
Fri, 16 Aug 2024 14:32:34 +0000 (15:32 +0100)
The arm_smmu_domain_alloc() function returns error pointers on error.  It
doesn't return NULL.  Update the error checking to match.

Fixes: 52acd7d8a413 ("iommu/arm-smmu-v3: Add support for domain_alloc_user fn")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/9208cd0d-8105-40df-93e9-bdcdf0d55eec@stanley.mountain
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

index a31460f9f3d4216b00ab27e0f051ea0cb42e9752..ac6c1597fb2d3d68d28382a7b83f3aae38c2f242 100644 (file)
@@ -3062,8 +3062,8 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags,
                return ERR_PTR(-EOPNOTSUPP);
 
        smmu_domain = arm_smmu_domain_alloc();
-       if (!smmu_domain)
-               return ERR_PTR(-ENOMEM);
+       if (IS_ERR(smmu_domain))
+               return ERR_CAST(smmu_domain);
 
        smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED;
        smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops;