On Wednesday 05 November 2014 20:32:52 al.stone@linaro.org wrote:
From: Mark Salter msalter@redhat.com
Fix a NULL dereference in find_mmu_master which occurs when booting with ACPI. In that case, PCI bridges with not have an of_node. Add a check for NULL of_node and bail out if that is the case.
Signed-off-by: Mark Salter msalter@redhat.com
drivers/iommu/arm-smmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 60558f7..dae8ae3 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -444,7 +444,10 @@ static struct device_node *dev_get_dev_node(struct device *dev) while (!pci_is_root_bus(bus)) bus = bus->parent;
return bus->bridge->parent->of_node;
if (bus->bridge->parent)
return bus->bridge->parent->of_node;
else
return bus->bridge->of_node; }
return dev->of_node;
I don't think we want to allow PCI host bridges without a parent device in DT, so you can just return NULL here.
@@ -560,6 +563,9 @@ static struct arm_smmu_device *find_smmu_for_device(struct device *dev) struct arm_smmu_master *master = NULL; struct device_node *dev_node = dev_get_dev_node(dev);
if (!dev_node)
return NULL;
spin_lock(&arm_smmu_devices_lock); list_for_each_entry(smmu, &arm_smmu_devices, list) { master = find_smmu_master(smmu, dev_node);
It might be good to mention in the changelog that this code is going to be reworked anyway, as change the iommu API to support the more general cases.
Arnd