Skip to contentSkip to conversation

iommu/arm-smmu: fix potential NULL pointer dereference in arm_smmu_map()

PATCH New Wei Yongjun 2 participants 2 messages Nov 15, 2013 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/arm-smmu: fix potential NULL pointer dereference in arm_smmu_map()

From: Wei Yongjun <[email protected]>

The dereference should be moved below the NULL test.

---
 drivers/iommu/arm-smmu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/arm-smmu.c +1 -2
index 2349d62..a0cc0a5 100644
@@ -1420,9 +1420,8 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,
 			phys_addr_t paddr, size_t size, int flags)
 {
 	struct arm_smmu_domain *smmu_domain = domain->priv;
-	struct arm_smmu_device *smmu = smmu_domain->leaf_smmu;
 
-	if (!smmu_domain || !smmu)
+	if (!smmu_domain || !smmu_domain->leaf_smmu)
 		return -ENODEV;
 
 	/* Check for silent address truncation up the SMMU chain. */
#1 lore raw

PATCH 1/1 iommu/arm-smmu: fix potential NULL pointer dereference in arm_smmu_map()

Quoted 14 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

The dereference should be moved below the NULL test.

---
 drivers/iommu/arm-smmu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/arm-smmu.c +0 -0
index 2349d62..a0cc0a5 100644

drivers/iommu/arm-smmu.c static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova, · line 1427

Quoted 10 lines
drivers/iommu/arm-smmu.c +1 -2
@@ -1420,9 +1420,8 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,
 			phys_addr_t paddr, size_t size, int flags)
 {
 	struct arm_smmu_domain *smmu_domain = domain->priv;
-	struct arm_smmu_device *smmu = smmu_domain->leaf_smmu;
 
-	if (!smmu_domain || !smmu)
+	if (!smmu_domain || !smmu_domain->leaf_smmu)
 		return -ENODEV;
 
 	/* Check for silent address truncation up the SMMU chain. */

I already have a patch for this, but actually, we can remove that check altogether. I'll fix it in my tree.

Will