Re: [PATCH v2] PCI: eswin: Fix resource leak on dw_pcie_host_init() failure
From: Felix Gu
Date: Thu May 21 2026 - 07:02:01 EST
On Thu, May 21, 2026 at 3:08 PM zhangsenchuan
<zhangsenchuan@xxxxxxxxxxxxxxxxxx> wrote:
> > --- a/drivers/pci/controller/dwc/pcie-eswin.c
> > +++ b/drivers/pci/controller/dwc/pcie-eswin.c
> > @@ -182,7 +182,7 @@ static int eswin_pcie_host_init(struct dw_pcie_rp *pp)
> > {
> > struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> > struct eswin_pcie *pcie = to_eswin_pcie(pci);
> > - struct eswin_pcie_port *port, *tmp;
> > + struct eswin_pcie_port *port;
> > u32 val;
> > int ret;
> >
> > @@ -252,10 +252,6 @@ static int eswin_pcie_host_init(struct dw_pcie_rp *pp)
> > reset_control_bulk_assert(ESWIN_NUM_RSTS, pcie->resets);
> > err_deassert:
> > clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks);
> > - list_for_each_entry_safe(port, tmp, &pcie->ports, list) {
> > - reset_control_put(port->perst);
> > - list_del(&port->list);
> > - }
>
> Hi, Felix
>
> If removed, in the dw_pcie_resume_noirq function, if the execution of
> "pci->pp.ops->init(&pci->pp)" fails, the resources will not be released.
>
Hi Senchuan,
Do we really need to release the port related resources in
dw_pcie_resume_noirq()
when pci->pp.ops->init(&pci->pp) fails?
And why not release the port related resources in the following error paths of
dw_pcie_resume_noirq()?
Best regards,
Felix
> Kind regards,
> Senchuan