[PATCH] pci: of : fix kernel crash

From: Murali Karicheri
Date: Fri Mar 06 2015 - 10:23:08 EST


This is a debug patch to root cause the kernel crash

commit 0b2af171520e5d5e7d5b5f479b90a6a5014d9df6

PCI: Update DMA configuration from DT

Signed-off-by: Murali Karicheri <m-karicheri2@xxxxxx>
---
drivers/of/of_pci.c | 8 ++++++++
drivers/pci/host-bridge.c | 5 +++++
2 files changed, 13 insertions(+)

diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index 86d3c38..5a59fb8 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -129,6 +129,14 @@ void of_pci_dma_configure(struct pci_dev *pci_dev)
struct device *dev = &pci_dev->dev;
struct device *bridge = pci_get_host_bridge_device(pci_dev);

+ if (!bridge || !bridge->parent) {
+ if (!bridge)
+ pr_err("PCI bridge not found\n");
+ if (!bridge->parent)
+ pr_err("PCI bridge parent not found\n");
+ return;
+ }
+
of_dma_configure(dev, bridge->parent->of_node);
pci_put_host_bridge_device(bridge);
}
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 3e5bbf9..ef2ab51 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -28,6 +28,11 @@ struct device *pci_get_host_bridge_device(struct pci_dev *dev)
struct pci_bus *root_bus = find_pci_root_bus(dev->bus);
struct device *bridge = root_bus->bridge;

+ if (!bridge) {
+ pr_err("PCI: bridge not found\n");
+ return NULL;
+ }
+
kobject_get(&bridge->kobj);
return bridge;
}
--
1.7.9.5


--------------010105020403020606070905--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/