summaryrefslogtreecommitdiff
path: root/drivers/pci/host/pci-imx6.c
diff options
context:
space:
mode:
authorRichard Zhu <hongxing.zhu@nxp.com>2018-06-11 17:07:19 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commitc3261ae898468c6aea2ed60ab06d6208c9862f2d (patch)
tree95ca28d9ab70064722af41c1475269fd49381f0d /drivers/pci/host/pci-imx6.c
parent9a0b70dcff37948e8f8f5e8153b5ed3388b8216c (diff)
MLK-18559 PCI: imx: fix crash when request reserved region
Fix the crash when pcie request the reserved memory region after the -EPROBE_DEFER in the probe. The pointer of the resource parameter would be invalided in the second probe. Use one structure varible to replace it. Put node after done with it, after call of_parse_phandle. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Diffstat (limited to 'drivers/pci/host/pci-imx6.c')
-rw-r--r--drivers/pci/host/pci-imx6.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index 01a7309b1f02..96fe59c6f16d 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -2144,7 +2144,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct imx_pcie *imx_pcie;
struct pcie_port *pp;
- struct resource *res;
+ struct resource *res, reserved_res;
struct device_node *reserved_node, *node = dev->of_node;
int ret;
@@ -2187,11 +2187,13 @@ static int imx_pcie_probe(struct platform_device *pdev)
if (!reserved_node) {
dev_info(dev, "no reserved region node.\n");
} else {
- if (of_address_to_resource(reserved_node, 0, res)) {
+ if (of_address_to_resource(reserved_node, 0, &reserved_res)) {
dev_err(dev, "failed to get reserved region address\n");
+ of_node_put(reserved_node);
return -EINVAL;
}
- ddr_test_region = res->start + SZ_2M;
+ ddr_test_region = reserved_res.start + SZ_2M;
+ of_node_put(reserved_node);
}
/* Fetch GPIOs */