Skip to content

Commit a7990c6

Browse files
sm00thjoergroedel
authored andcommitted
iommu/arm-smmu: fix null-pointer dereference in arm_smmu_add_device
Commit c54451a "iommu/arm-smmu: Fix the error path in arm_smmu_add_device" removed fwspec assignment in legacy_binding path as redundant which is wrong. It needs to be updated after fwspec initialisation in arm_smmu_register_legacy_master() as it is dereferenced later. Without this there is a NULL-pointer dereference panic during boot on some hosts. Signed-off-by: Artem Savkov <[email protected]> Reviewed-by: Robin Murphy <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 74ddda7 commit a7990c6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/iommu/arm-smmu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,13 @@ static int arm_smmu_add_device(struct device *dev)
15191519

15201520
if (using_legacy_binding) {
15211521
ret = arm_smmu_register_legacy_master(dev, &smmu);
1522+
1523+
/*
1524+
* If dev->iommu_fwspec is initally NULL, arm_smmu_register_legacy_master()
1525+
* will allocate/initialise a new one. Thus we need to update fwspec for
1526+
* later use.
1527+
*/
1528+
fwspec = dev->iommu_fwspec;
15221529
if (ret)
15231530
goto out_free;
15241531
} else if (fwspec && fwspec->ops == &arm_smmu_ops) {

0 commit comments

Comments
 (0)