From 2c7a8e4126886ae4c076e3d52d001fd2a81250fa Mon Sep 17 00:00:00 2001 From: Sushanth Vadapally Date: Tue, 26 Sep 2023 12:31:33 +0530 Subject: [PATCH] iommu/arm-smmu: Checks added for NULL pointer Added NULL checks to avoid NULL pointer dereference. Change-Id: Id418925d708fa6bcafb37991d770d4ac7e2a69d9 Signed-off-by: Sushanth Vadapally Signed-off-by: Madhu Ananthula --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index f4910bf6aa61..fa8b0ab06d7e 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -453,14 +453,14 @@ static int __arm_smmu_alloc_cb(unsigned long *map, int start, int end, { struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); - struct arm_smmu_device *smmu = cfg->smmu; + struct arm_smmu_device *smmu; int idx; int i; int cb = -EINVAL; if (!fwspec || !cfg) return cb; - + smmu = cfg->smmu; for_each_cfg_sme(cfg, fwspec, i, idx) { if (smmu->s2crs[idx].pinned) cb = smmu->s2crs[idx].cbndx;