PCI: faraday: Fix host bridge memory leakage
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Wed, 28 Jun 2017 20:13:53 +0000 (15:13 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 28 Jun 2017 20:13:53 +0000 (15:13 -0500)
When probing the PCI host controller driver, if an error occurs, the probe
function code does not free memory allocated for the struct pci_host_bridge
resulting in memory leakage.

Move the struct pci_host_bridge allocation over to the respective devm
interface to fix the issue.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
drivers/pci/host/pci-ftpci100.c

index 1ad6b253b32546ac4b97c5d04a43ad8189098829..ce5700eec1dae41328b94725fc3e3899df0e0240 100644 (file)
@@ -448,7 +448,7 @@ static int faraday_pci_probe(struct platform_device *pdev)
        u32 val;
        LIST_HEAD(res);
 
-       host = pci_alloc_host_bridge(sizeof(*p));
+       host = devm_pci_alloc_host_bridge(dev, sizeof(*p));
        if (!host)
                return -ENOMEM;