Skip to content

Commit d9ed8af

Browse files
Yang Yingliangwilldeacon
authored andcommitted
iommu/arm-smmu: fix possible null-ptr-deref in arm_smmu_device_probe()
It will cause null-ptr-deref when using 'res', if platform_get_resource() returns NULL, so move using 'res' after devm_ioremap_resource() that will check it to avoid null-ptr-deref. And use devm_platform_get_and_ioremap_resource() to simplify code. Signed-off-by: Yang Yingliang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 5a4eb91 commit d9ed8af

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,11 +2092,10 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
20922092
if (err)
20932093
return err;
20942094

2095-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2096-
ioaddr = res->start;
2097-
smmu->base = devm_ioremap_resource(dev, res);
2095+
smmu->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
20982096
if (IS_ERR(smmu->base))
20992097
return PTR_ERR(smmu->base);
2098+
ioaddr = res->start;
21002099
/*
21012100
* The resource size should effectively match the value of SMMU_TOP;
21022101
* stash that temporarily until we know PAGESIZE to validate it with.

0 commit comments

Comments
 (0)