UPSTREAM: PCI: rockchip: Fix rockchip_pcie_probe() error path to free resource list
authorShawn Lin <shawn.lin@rock-chips.com>
Fri, 10 Feb 2017 06:52:02 +0000 (14:52 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 16 Mar 2017 03:25:30 +0000 (11:25 +0800)
rockchip_pcie_probe() calls of_pci_get_host_bridge_resources() to parse
resources from DT and build a resource list.  The caller is responsible for
disposing of the resource list.  This is normally done by
pci_release_host_bridge_dev() when the host bridge is removed.

If the host bridge probe fails, dispose of the resource list in the probe
error path.

Change-Id: Iefc17963a6ce99c64f2940d8dc2ba93bd00fe120
[bhelgaas: changelog]
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
(cherry picked from f1d722b607d610b66785f7f00d2e1d457260647c)

drivers/pci/host/pcie-rockchip.c

index fc7078d..26ddd35 100644 (file)
@@ -1343,7 +1343,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
 
        err = devm_request_pci_bus_resources(dev, &res);
        if (err)
-               goto err_vpcie;
+               goto err_free_res;
 
        /* Get the I/O and memory ranges from DT */
        resource_list_for_each_entry(win, &res) {
@@ -1376,19 +1376,19 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
 
        err = rockchip_cfg_atu(rockchip);
        if (err)
-               goto err_vpcie;
+               goto err_free_res;
 
        rockchip->msg_region = devm_ioremap(rockchip->dev,
                                            rockchip->msg_bus_addr, SZ_1M);
        if (!rockchip->msg_region) {
                err = -ENOMEM;
-               goto err_vpcie;
+               goto err_free_res;
        }
 
        bus = pci_scan_root_bus(&pdev->dev, 0, &rockchip_pcie_ops, rockchip, &res);
        if (!bus) {
                err = -ENOMEM;
-               goto err_vpcie;
+               goto err_free_res;
        }
 
        pci_bus_size_bridges(bus);
@@ -1399,6 +1399,8 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
        pci_bus_add_devices(bus);
        return err;
 
+err_free_res:
+       pci_free_resource_list(&res);
 err_vpcie:
        if (!IS_ERR(rockchip->vpcie3v3))
                regulator_disable(rockchip->vpcie3v3);