linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Z.q. Hou" <zhiqiang.hou@nxp.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"jingoohan1@gmail.com" <jingoohan1@gmail.com>,
	"gustavo.pimentel@synopsys.com" <gustavo.pimentel@synopsys.com>,
	Roy Zang <roy.zang@nxp.com>, Mingkai Hu <mingkai.hu@nxp.com>,
	"M.h. Lian" <minghuan.lian@nxp.com>
Subject: RE: [PATCHv2 1/4] PCI: dwc: fix potential memory leak
Date: Thu, 6 Dec 2018 01:08:14 +0000	[thread overview]
Message-ID: <AM6PR04MB5781A44014DD60973E393A6B84A90@AM6PR04MB5781.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20181205154013.GA18294@e107981-ln.cambridge.arm.com>

Hi Lorenzo,

> -----Original Message-----
> From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Sent: 2018年12月5日 23:40
> To: Z.q. Hou <zhiqiang.hou@nxp.com>
> Cc: linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org;
> bhelgaas@google.com; jingoohan1@gmail.com;
> gustavo.pimentel@synopsys.com; Roy Zang <roy.zang@nxp.com>; Mingkai Hu
> <mingkai.hu@nxp.com>; M.h. Lian <minghuan.lian@nxp.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@nxp.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@nxp.com>
> > Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.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.

Yes, I just understood.

> Lorenzo
> 
> >  	pci_free_host_bridge(bridge);
> >  	return ret;
> >  }
> > --
> > 2.17.1
> >
Thanks,
Zhiqiang

  reply	other threads:[~2018-12-06  1:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07 10:08 [PATCHv2 0/4] PCI: dwc: add prefetchable memory range support Z.q. Hou
2018-11-07 10:09 ` [PATCHv2 1/4] PCI: dwc: fix potential memory leak Z.q. Hou
2018-12-05 15:40   ` Lorenzo Pieralisi
2018-12-06  1:08     ` Z.q. Hou [this message]
2018-11-07 10:09 ` [PATCHv2 2/4] PCI: dwc: fix 4GiB outbound window size truncated to zero issue Z.q. Hou
2018-12-05 16:01   ` Lorenzo Pieralisi
2018-12-06  1:25     ` Z.q. Hou
2018-12-11 14:40       ` Lorenzo Pieralisi
2018-11-07 10:09 ` [PATCHv2 3/4] PCI: layerscape: initialize the number of viewport Z.q. Hou
2018-11-22 11:16   ` Lorenzo Pieralisi
2018-11-23  6:01     ` Z.q. Hou
2018-11-07 10:09 ` [PATCHv2 4/4] PCI: dwc: add prefetchable memory range support Z.q. Hou
2018-11-21 17:36   ` Gustavo Pimentel
2018-11-22  1:03     ` Z.q. Hou
2018-11-28 17:59   ` Lorenzo Pieralisi
2018-12-11 10:21     ` Z.q. Hou
2018-12-11 15:19       ` Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM6PR04MB5781A44014DD60973E393A6B84A90@AM6PR04MB5781.eurprd04.prod.outlook.com \
    --to=zhiqiang.hou@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=jingoohan1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=minghuan.lian@nxp.com \
    --cc=mingkai.hu@nxp.com \
    --cc=roy.zang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).