Skip to content

Commit 7d96990

Browse files
GuEe-GUIRbb666
authored andcommitted
[DM/PCI] Fixup the DWC PCI resource release
Signed-off-by: GuEe-GUI <[email protected]>
1 parent 77e845e commit 7d96990

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

components/drivers/pci/host/dw/pcie-dw_host.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ void dw_pcie_free_msi(struct dw_pcie_port *port)
204204

205205
rt_dma_free_coherent(pci->dev, sizeof(rt_uint64_t), port->msi_data,
206206
port->msi_data_phy);
207+
port->msi_data = RT_NULL;
207208
}
208209
}
209210

@@ -331,7 +332,8 @@ rt_err_t dw_pcie_host_init(struct dw_pcie_port *port)
331332
{
332333
LOG_E("Invalid count of irq = %d", port->irq_count);
333334

334-
return -RT_EINVAL;
335+
err = -RT_EINVAL;
336+
goto _err_free_cfg;
335337
}
336338
}
337339

@@ -341,7 +343,8 @@ rt_err_t dw_pcie_host_init(struct dw_pcie_port *port)
341343

342344
if (!port->msi_pic)
343345
{
344-
return -RT_ENOMEM;
346+
err = -RT_ENOMEM;
347+
goto _err_free_cfg;
345348
}
346349

347350
port->msi_pic->priv_data = port;
@@ -404,6 +407,13 @@ rt_err_t dw_pcie_host_init(struct dw_pcie_port *port)
404407
rt_pci_host_bridge_free(bridge);
405408
port->bridge = RT_NULL;
406409

410+
_err_free_cfg:
411+
if (port->cfg0_base)
412+
{
413+
rt_iounmap(port->cfg0_base);
414+
port->cfg0_base = RT_NULL;
415+
}
416+
407417
return err;
408418
}
409419

0 commit comments

Comments
 (0)