iommu/arm-smmu: Handle unknown CERROR values gracefully
authorWill Deacon <will.deacon@arm.com>
Fri, 4 Dec 2015 12:00:29 +0000 (12:00 +0000)
committerWill Deacon <will.deacon@arm.com>
Thu, 17 Dec 2015 12:05:33 +0000 (12:05 +0000)
Whilst the architecture only defines a few of the possible CERROR values,
we should handle unknown values gracefully rather than go out of bounds
trying to print out an error description.

Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/arm-smmu-v3.c

index 3ea4d576bf087f0be0ea9457229ef179f26dc660..4c5ef4e5da98ebf9dfda7d63b5895fb6d8206592 100644 (file)
@@ -857,15 +857,17 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu)
        };
 
        dev_err(smmu->dev, "CMDQ error (cons 0x%08x): %s\n", cons,
-               cerror_str[idx]);
+               idx < ARRAY_SIZE(cerror_str) ?  cerror_str[idx] : "Unknown");
 
        switch (idx) {
-       case CMDQ_ERR_CERROR_ILL_IDX:
-               break;
        case CMDQ_ERR_CERROR_ABT_IDX:
                dev_err(smmu->dev, "retrying command fetch\n");
        case CMDQ_ERR_CERROR_NONE_IDX:
                return;
+       case CMDQ_ERR_CERROR_ILL_IDX:
+               /* Fallthrough */
+       default:
+               break;
        }
 
        /*