[PATCH] Staging: iommu: Replace null pointer check with IS_ERR in arm_smmu_domain_alloc_user()
Dipendra Khadka
kdipendra88 at gmail.com
Sun Sep 22 08:56:20 PDT 2024
The smatch reported following:
'''
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3065 arm_smmu_domain_alloc_user() warn: 'smmu_domain' is an error pointer or valid
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:3068 arm_smmu_domain_alloc_user() error: 'smmu_domain' dereferencing possible ERR_PTR()
'''
The function arm_smmu_domain_alloc() handles the null pointer after
kzalloc and returns ERR_PTR(-ENOMEM).
Replacing condition check !smmu_domain with IS_ERR(smmu_domain) and
returning smmu_domain.
Signed-off-by: Dipendra Khadka <kdipendra88 at gmail.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index a31460f9f3d4..19c53c6f7578 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -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 smmu_domain;
smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED;
smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops;
--
2.43.0
More information about the linux-arm-kernel
mailing list