PCI: dwc: solve returning success but actually failed
PATCH 1/1 PCI: dwc: solve returning success but actually failed
When dma_mapping_error returns error because of no enough memory available, dw_pcie_host_init will return success, which will mislead the callers.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 1 + 1 file changed, 1 insertion(+)
(quoted diff) +0 -0
b/drivers/pci/controller/dwc/pcie-designware-host.c index f4755f3a03be..ac691d733848 100644
drivers/pci/controller/dwc/pcie-designware-host.c +1 -0
@@ -393,6 +393,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 = -1; goto err_free_msi; } }
--
2.17.1
Rob Herring
reviewerQuoted 1 line · Zhangjiantao(Kirin,Nanjing)
For the subject, something like: 'PCI: dwc: Fix setting error return on MSI DMA mapping failure'
Quoted 1 line
When
dma_mapping_errorreturns error because of no enough memory available,dw_pcie_host_initwill return success, which will mislead the callers.
Wrap lines at 72 char.
Quoted 1 line
Add a Fixes tag with whatever commit introduced the problem.
Quoted 2 lines
Signed-off-by zhangjianrong <[email protected]>Signed-off-by zhangjiantao <[email protected]>
Author and S-o-b names should match.
Quoted 11 lines
--- drivers/pci/controller/dwc/pcie-designware-host.c | 1 + 1 file changed, 1 insertion(+)drivers/pci/controller/dwc/pcie-designware-host.c +0
-0
drivers/pci/controller/dwc/pcie-designware-host.c int dw_pcie_host_init(struct pcie_port *pp) · line 396
Quoted 4 lines
drivers/pci/controller/dwc/pcie-designware-host.c +1
-0@@ -393,6 +393,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 =-1 ;
Use an errno value. ENOMEM seems to be common, but I also see EIO and EFAULT used.
Rob
Quoted 1 line · Zhangjiantao(Kirin,Nanjing)
When
dma_mapping_errorreturns error because of no enough memory available,dw_pcie_host_initwill return success, which will mislead the callers.
Wrap to fit in 75 columns, add "()" after function names.
Quoted 14 lines
Signed-off-by zhangjianrong <[email protected]>Signed-off-by zhangjiantao <[email protected]>--- drivers/pci/controller/dwc/pcie-designware-host.c | 1 + 1 file changed, 1 insertion(+)drivers/pci/controller/dwc/pcie-designware-host.c +0
-0
drivers/pci/controller/dwc/pcie-designware-host.c int dw_pcie_host_init(struct pcie_port *pp) · line 396
Quoted 4 lines
drivers/pci/controller/dwc/pcie-designware-host.c +1
-0@@ -393,6 +393,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 = -1;
We should save the return value from dma_mapping_error() and return *that*, not -1.
Whitespace error (indent with tabs, same as the surrounding code).
Quoted 6 lines
drivers/pci/controller/dwc/pcie-designware-host.c +0
-1goto err_free_msi; } } --2.17.1