Skip to contentSkip to conversation

iommu/arm-smmu: fix a signedness bug

PATCH In review Dan Carpenter 2 participants 2 messages Aug 21, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 iommu/arm-smmu: fix a signedness bug

Unsigned char is never equal to -1.

---
I can't compile this code.

drivers/iommu/arm-smmu.c +3 -2
index f417e89e..7243af3 100644
@@ -377,6 +377,7 @@ struct arm_smmu_cfg {
 	u32				cbar;
 	pgd_t				*pgd;
 };
+#define INVALID_IRPTNDX			0xff
 
 #define ARM_SMMU_CB_ASID(cfg)		((cfg)->cbndx)
 #define ARM_SMMU_CB_VMID(cfg)		((cfg)->cbndx + 1)
@@ -840,7 +841,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
 	if (IS_ERR_VALUE(ret)) {
 		dev_err(smmu->dev, "failed to request context IRQ %d (%u)\n",
 			root_cfg->irptndx, irq);
-		root_cfg->irptndx = -1;
+		root_cfg->irptndx = INVALID_IRPTNDX;
 		goto out_free_context;
 	}
 
@@ -869,7 +870,7 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain)
 	writel_relaxed(0, cb_base + ARM_SMMU_CB_SCTLR);
 	arm_smmu_tlb_inv_context(root_cfg);
 
-	if (root_cfg->irptndx != -1) {
+	if (root_cfg->irptndx != INVALID_IRPTNDX) {
 		irq = smmu->irqs[smmu->num_global_irqs + root_cfg->irptndx];
 		free_irq(irq, domain);
 	}
#1 lore raw

Hi Dan,

Quoted 1 line · Dan Carpenter

Unsigned char is never equal to -1.

D'oh! Thanks for the patches.

Quoted 3 lines

---
I can't compile this code.

I've compiled and tested both of them with an AArch32 MMU-500 model and they work fine. I'll send this lot in Joerg's direction with the other patches I currently have queued.

Cheers,

Will