]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
PCI: iproc: Fix NULL pointer dereference for BCMA
authorRay Jui <ray.jui@broadcom.com>
Thu, 11 Jan 2018 20:36:16 +0000 (12:36 -0800)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 23 Feb 2018 14:27:23 +0000 (08:27 -0600)
BugLink: http://bugs.launchpad.net/bugs/1751131
commit 3b65ca50d24ce33cb92d88840e289135c92b40ed upstream.

With the inbound DMA mapping supported added, the iProc PCIe driver
parses DT property "dma-ranges" through call to
"of_pci_dma_range_parser_init()". In the case of BCMA, this results in a
NULL pointer deference due to a missing of_node.

Fix this by adding a guard in pcie-iproc-platform.c to only enable the
inbound DMA mapping logic when DT property "dma-ranges" is present.

Fixes: dd9d4e7498de3 ("PCI: iproc: Add inbound DMA mapping support")
Reported-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Ray Jui <ray.jui@broadcom.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Rafał Miłecki <rafal@milecki.pl>
cc: <stable@vger.kernel.org> # 4.10+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/pci/host/pcie-iproc-platform.c
drivers/pci/host/pcie-iproc.c
drivers/pci/host/pcie-iproc.h

index a5073a921a049c483fe412a7939f3d6579a7a8c8..32228d41f7462d6c5a467626f94502ef0b30ab66 100644 (file)
@@ -92,6 +92,13 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
                pcie->need_ob_cfg = true;
        }
 
+       /*
+        * DT nodes are not used by all platforms that use the iProc PCIe
+        * core driver. For platforms that require explict inbound mapping
+        * configuration, "dma-ranges" would have been present in DT
+        */
+       pcie->need_ib_cfg = of_property_read_bool(np, "dma-ranges");
+
        /* PHY use is optional */
        pcie->phy = devm_phy_get(dev, "pcie-phy");
        if (IS_ERR(pcie->phy)) {
index 935909bbe5c45e381725cd34b0851858251c72c7..75836067f538404b4ee407aff4a14022f1279b63 100644 (file)
@@ -1378,9 +1378,11 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)
                }
        }
 
-       ret = iproc_pcie_map_dma_ranges(pcie);
-       if (ret && ret != -ENOENT)
-               goto err_power_off_phy;
+       if (pcie->need_ib_cfg) {
+               ret = iproc_pcie_map_dma_ranges(pcie);
+               if (ret && ret != -ENOENT)
+                       goto err_power_off_phy;
+       }
 
 #ifdef CONFIG_ARM
        pcie->sysdata.private_data = pcie;
index a6b55cec9a668e6124e6ca43ec2d4ec87732a0c3..4ac6282f2bfd60ab4c26589c74376fa2a9e1dc8f 100644 (file)
@@ -74,6 +74,7 @@ struct iproc_msi;
  * @ob: outbound mapping related parameters
  * @ob_map: outbound mapping related parameters specific to the controller
  *
+ * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
  * @ib: inbound mapping related parameters
  * @ib_map: outbound mapping region related parameters
  *
@@ -101,6 +102,7 @@ struct iproc_pcie {
        struct iproc_pcie_ob ob;
        const struct iproc_pcie_ob_map *ob_map;
 
+       bool need_ib_cfg;
        struct iproc_pcie_ib ib;
        const struct iproc_pcie_ib_map *ib_map;