[PATCH 4/4] perf/smmuv3: fix crash when platdata not specified

Ajay Kumar ajaykumar.rs at samsung.com
Sun Jul 12 12:33:41 EDT 2020


The arm_smmuv3_pmu driver assumes platform data is always
available and exposes a possible NULL pointer deferencing
at the below line.

model = *(u32 *)dev_get_platdata(smmu_pmu->dev);

This patch fixes the bug by adding a check prior to the
deferencing of the platform data pointer.

Signed-off-by: Ajay Kumar <ajaykumar.rs at samsung.com>
---
 drivers/perf/arm_smmuv3_pmu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
index 25feab718c20..f7a27ae2f8d8 100644
--- a/drivers/perf/arm_smmuv3_pmu.c
+++ b/drivers/perf/arm_smmuv3_pmu.c
@@ -710,9 +710,10 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu)
 
 static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu)
 {
-	u32 model;
+	u32 model = 0;
 
-	model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
+	if (dev_get_platdata(smmu_pmu->dev))
+		model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
 
 	switch (model) {
 	case IORT_SMMU_V3_PMCG_HISI_HIP08:
-- 
2.17.1




More information about the linux-arm-kernel mailing list