iommu/arm-smmu: Fix the error path in arm_smmu_add_device
fwspec->iommu_priv is available only after arm_smmu_master_cfg instance has been allocated. We shouldn't free it before that. Also it's logical to free the master cfg itself without checking for fwspec. Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> [will: remove redundant assignment to fwspec] Signed-off-by: Will Deacon <will.deacon@arm.com>
This commit is contained in:
parent
2984f7f3bb
commit
c54451a5e2
@ -1519,7 +1519,6 @@ static int arm_smmu_add_device(struct device *dev)
|
|||||||
|
|
||||||
if (using_legacy_binding) {
|
if (using_legacy_binding) {
|
||||||
ret = arm_smmu_register_legacy_master(dev, &smmu);
|
ret = arm_smmu_register_legacy_master(dev, &smmu);
|
||||||
fwspec = dev->iommu_fwspec;
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
} else if (fwspec && fwspec->ops == &arm_smmu_ops) {
|
} else if (fwspec && fwspec->ops == &arm_smmu_ops) {
|
||||||
@ -1558,15 +1557,15 @@ static int arm_smmu_add_device(struct device *dev)
|
|||||||
|
|
||||||
ret = arm_smmu_master_alloc_smes(dev);
|
ret = arm_smmu_master_alloc_smes(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free;
|
goto out_cfg_free;
|
||||||
|
|
||||||
iommu_device_link(&smmu->iommu, dev);
|
iommu_device_link(&smmu->iommu, dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_cfg_free:
|
||||||
|
kfree(cfg);
|
||||||
out_free:
|
out_free:
|
||||||
if (fwspec)
|
|
||||||
kfree(fwspec->iommu_priv);
|
|
||||||
iommu_fwspec_free(dev);
|
iommu_fwspec_free(dev);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user