Skip to contentSkip to conversation

PCI: dwc: fix error return code in dw_pcie_host_init()

PATCH Superseded Wang Hai 2 participants 3 messages Nov 16, 2020 – Nov 17, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 PCI: dwc: fix error return code in dw_pcie_host_init()

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

Fixes 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume")
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pcie-designware-host.c +1 -0
index 44c2a6572199..7b3c91c6ae02 100644
@@ -395,6 +395,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
 			if (dma_mapping_error(pci->dev, pp->msi_data)) {
 				dev_err(pci->dev, "Failed to map MSI data\n");
 				pp->msi_data = 0;
+				ret = -ENOMEM;
 				goto err_free_msi;
 			}
 		} else {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · On Mon, 16 Nov 2020 21:50:23 +0800 Wang Hai wrote:

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

good catch.

Quoted 13 lines
Fixes 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume")
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pcie-designware-host.c +0 -0
index 44c2a6572199..7b3c91c6ae02 100644

drivers/pci/controller/dwc/pcie-designware-host.c int dw_pcie_host_init(struct pcie_port *pp) · line 398

Quoted 4 lines
drivers/pci/controller/dwc/pcie-designware-host.c +1 -0
@@ -395,6 +395,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
                        if (dma_mapping_error(pci->dev, pp->msi_data)) {
                                dev_err(pci->dev, "Failed to map MSI data\n");
                                pp->msi_data = 0;
+                               ret = -ENOMEM;

what about use the return value of dma_maping_error()? I.E

ret = dma_mapping_error()
if (ret) {
....
}

Quoted 6 lines
drivers/pci/controller/dwc/pcie-designware-host.c +0 -1
                                goto err_free_msi;
                        }
                } else {
--

2.17.1

#2 lore raw
Quoted 15 lines · Jisheng Zhang
Quoted 3 lines · On Mon, 16 Nov 2020 21:50:23 +0800 Wang Hai wrote:

Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.

good catch.

Quoted 8 lines
Fixes 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume")
                         if (dma_mapping_error(pci->dev, pp->msi_data)) {
                                 dev_err(pci->dev, "Failed to map MSI data\n");
                                 pp->msi_data = 0;

+ ret = -ENOMEM;

Quoted 7 lines

what about use the return value of dma_maping_error()? I.E

ret = dma_mapping_error()
if (ret) {
....
}

Thanks for your review,  I just sent v2

"[PATCH v2] PCI: dwc: fix error return code in dw_pcie_host_init()"

Quoted 2 lines

.