[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181205154013.GA18294@e107981-ln.cambridge.arm.com>
Date: Wed, 5 Dec 2018 15:40:13 +0000
From: Lorenzo Pieralisi <lorenzo.pieralisi@....com>
To: "Z.q. Hou" <zhiqiang.hou@....com>
Cc: "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"bhelgaas@...gle.com" <bhelgaas@...gle.com>,
"jingoohan1@...il.com" <jingoohan1@...il.com>,
"gustavo.pimentel@...opsys.com" <gustavo.pimentel@...opsys.com>,
Roy Zang <roy.zang@....com>, Mingkai Hu <mingkai.hu@....com>,
"M.h. Lian" <minghuan.lian@....com>
Subject: Re: [PATCHv2 1/4] PCI: dwc: fix potential memory leak
On Wed, Nov 07, 2018 at 10:09:04AM +0000, Z.q. Hou wrote:
> From: Hou Zhiqiang <Zhiqiang.Hou@....com>
>
> Free the allocated pci_host_bridge struct when failed to get
> host bridge resources, and free the resource windows before
> free the bridge.
>
> Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@....com>
> Acked-by: Gustavo Pimentel <gustavo.pimentel@...opsys.com>
> ---
> V2:
> - Reworded the subject.
>
> drivers/pci/controller/dwc/pcie-designware-host.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index 29a05759a294..ecacce016489 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -353,7 +353,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
> ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff,
> &bridge->windows, &pp->io_base);
> if (ret)
> - return ret;
> + goto error;
>
> ret = devm_request_pci_bus_resources(dev, &bridge->windows);
> if (ret)
> @@ -502,6 +502,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
> return 0;
>
> error:
> + pci_free_resource_list(&bridge->windows);
This would cause a double-free, devm_request_pci_bus_resource already
takes care of freeing resources, patch dropped.
Lorenzo
> pci_free_host_bridge(bridge);
> return ret;
> }
> --
> 2.17.1
>
Powered by blists - more mailing lists