* [PATCH2] PCI: dwc: solve returning success but actually failed @ 2022-03-08 15:45 Zhangjiantao(Kirin,Nanjing) 2022-03-08 17:03 ` Rob Herring 0 siblings, 1 reply; 5+ messages in thread From: Zhangjiantao(Kirin,Nanjing) @ 2022-03-08 15:45 UTC (permalink / raw) To: Bjorn Helgaas, robh Cc: jingoohan1, gustavo.pimentel, lorenzo.pieralisi, kw, linux-pci, linux-kernel, zhangjianrong (E) When dma_mapping_error() returns error because of no enough memory available, dw_pcie_host_init() will return success, which will mislead the callers. Fixes: 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume") Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com> Signed-off-by: Jianrong Zhang <zhangjianrong5@huawei.com> --- 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 f4755f3a03be..9dcb51728dd1 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -390,7 +390,8 @@ int dw_pcie_host_init(struct pcie_port *pp) sizeof(pp->msi_msg), DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); - if (dma_mapping_error(pci->dev, pp->msi_data)) { + ret = dma_mapping_error(pci->dev, pp->msi_data); + if (ret) { dev_err(pci->dev, "Failed to map MSI data\n"); pp->msi_data = 0; goto err_free_msi; -- 2.17.1 Jiantao Zhang On 2022/3/5 5:39, Bjorn Helgaas wrote: > On Fri, Mar 04, 2022 at 12:06:10PM +0000, Zhangjiantao(Kirin,Nanjing) wrote: >> When dma_mapping_error returns error because of no enough memory available, dw_pcie_host_init will return success, which will mislead the callers. > Wrap to fit in 75 columns, add "()" after function names. >> Signed-off-by: zhangjianrong <zhangjianrong5@huawei.com> >> Signed-off-by: zhangjiantao <water.zhangjiantao@huawei.com> >> >> --- >> drivers/pci/controller/dwc/pcie-designware-host.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c >> b/drivers/pci/controller/dwc/pcie-designware-host.c >> index f4755f3a03be..ac691d733848 100644 >> --- a/drivers/pci/controller/dwc/pcie-designware-host.c >> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c >> @@ -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). > >> goto err_free_msi; >> } >> } >> -- >> 2.17.1 >> > . ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH2] PCI: dwc: solve returning success but actually failed 2022-03-08 15:45 [PATCH2] PCI: dwc: solve returning success but actually failed Zhangjiantao(Kirin,Nanjing) @ 2022-03-08 17:03 ` Rob Herring 2022-03-09 12:01 ` [PATCH v2] PCI: dwc: Fix setting error return on MSI DMA mapping failure Jiantao Zhang 0 siblings, 1 reply; 5+ messages in thread From: Rob Herring @ 2022-03-08 17:03 UTC (permalink / raw) To: Zhangjiantao(Kirin,Nanjing) Cc: Bjorn Helgaas, jingoohan1, gustavo.pimentel, lorenzo.pieralisi, kw, linux-pci, linux-kernel, zhangjianrong (E) On Tue, Mar 8, 2022 at 9:45 AM Zhangjiantao(Kirin,Nanjing) <water.zhangjiantao@huawei.com> wrote: > > When dma_mapping_error() returns error because of no enough memory available, dw_pcie_host_init() will return success, which will mislead the callers. Again, wrap long lines. And please reword the subject as I previously suggested. It should be 'PATCH v2', not 'PATCH2' in the subject. 'git send-email -v2' does that for you. > > Fixes: 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume") > Drop the blank line here. > Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com> As you are sending the patch, your S-o-b goes last. And the author name still doesn't match here: 'Jiantao Zhang' vs. 'Zhangjiantao(Kirin,Nanjing)' > Signed-off-by: Jianrong Zhang <zhangjianrong5@huawei.com> > --- > 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 f4755f3a03be..9dcb51728dd1 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-host.c > +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > @@ -390,7 +390,8 @@ int dw_pcie_host_init(struct pcie_port *pp) > sizeof(pp->msi_msg), > DMA_FROM_DEVICE, > DMA_ATTR_SKIP_CPU_SYNC); > - if (dma_mapping_error(pci->dev, pp->msi_data)) { > + ret = dma_mapping_error(pci->dev, pp->msi_data); > + if (ret) { > dev_err(pci->dev, "Failed to map MSI data\n"); > pp->msi_data = 0; > goto err_free_msi; > -- > 2.17.1 > > Jiantao Zhang > > On 2022/3/5 5:39, Bjorn Helgaas wrote: > > On Fri, Mar 04, 2022 at 12:06:10PM +0000, Zhangjiantao(Kirin,Nanjing) wrote: All this should not be in new versions of patches. > >> When dma_mapping_error returns error because of no enough memory available, dw_pcie_host_init will return success, which will mislead the callers. > > Wrap to fit in 75 columns, add "()" after function names. > >> Signed-off-by: zhangjianrong <zhangjianrong5@huawei.com> > >> Signed-off-by: zhangjiantao <water.zhangjiantao@huawei.com> > >> > >> --- > >> drivers/pci/controller/dwc/pcie-designware-host.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c > >> b/drivers/pci/controller/dwc/pcie-designware-host.c > >> index f4755f3a03be..ac691d733848 100644 > >> --- a/drivers/pci/controller/dwc/pcie-designware-host.c > >> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > >> @@ -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). > > > >> goto err_free_msi; > >> } > >> } > >> -- > >> 2.17.1 > >> > > . ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] PCI: dwc: Fix setting error return on MSI DMA mapping failure 2022-03-08 17:03 ` Rob Herring @ 2022-03-09 12:01 ` Jiantao Zhang 2022-03-24 21:04 ` Rob Herring 2022-04-08 14:43 ` Lorenzo Pieralisi 0 siblings, 2 replies; 5+ messages in thread From: Jiantao Zhang @ 2022-03-09 12:01 UTC (permalink / raw) To: robh, Bjorn Helgaas, jingoohan1, gustavo.pimentel, lorenzo.pieralisi, kw, linux-pci, linux-kernel, zhangjianrong (E) Cc: caiyadong, xuetao (kirin), xuhaiyang, songxiaowei, guhengsheng When dma_mapping_error() returns error because of no enough memory, but dw_pcie_host_init() returns success, which will mislead the callers. Fixes: 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume") Signed-off-by: Jianrong Zhang <zhangjianrong5@huawei.com> Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com> --- 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 f4755f3a03be..9dcb51728dd1 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -390,7 +390,8 @@ int dw_pcie_host_init(struct pcie_port *pp) sizeof(pp->msi_msg), DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); - if (dma_mapping_error(pci->dev, pp->msi_data)) { + ret = dma_mapping_error(pci->dev, pp->msi_data); + if (ret) { dev_err(pci->dev, "Failed to map MSI data\n"); pp->msi_data = 0; goto err_free_msi; -- 2.17.1 Jiantao Zhang On Tue, Mar 8, 2022 at 9:45 AM Zhangjiantao(Kirin,Nanjing) <water.zhangjiantao@huawei.com> wrote: > When dma_mapping_error() returns error because of no enough memory available, dw_pcie_host_init() will return success, which will mislead the callers. Again, wrap long lines. And please reword the subject as I previously suggested. It should be 'PATCH v2', not 'PATCH2' in the subject. 'git send-email -v2' does that for you. > Fixes: 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume") > Drop the blank line here. > Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com> As you are sending the patch, your S-o-b goes last. And the author name still doesn't match here: 'Jiantao Zhang' vs. 'Zhangjiantao(Kirin,Nanjing)' > Signed-off-by: Jianrong Zhang <zhangjianrong5@huawei.com> > --- > 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 f4755f3a03be..9dcb51728dd1 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-host.c > +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > @@ -390,7 +390,8 @@ int dw_pcie_host_init(struct pcie_port *pp) > sizeof(pp->msi_msg), > DMA_FROM_DEVICE, > DMA_ATTR_SKIP_CPU_SYNC); > - if (dma_mapping_error(pci->dev, pp->msi_data)) { > + ret = dma_mapping_error(pci->dev, pp->msi_data); > + if (ret) { > dev_err(pci->dev, "Failed to map MSI data\n"); > pp->msi_data = 0; > goto err_free_msi; > -- > 2.17.1 > > Jiantao Zhang > > On 2022/3/5 5:39, Bjorn Helgaas wrote: >> On Fri, Mar 04, 2022 at 12:06:10PM +0000, Zhangjiantao(Kirin,Nanjing) wrote: All this should not be in new versions of patches. >>> When dma_mapping_error returns error because of no enough memory available, dw_pcie_host_init will return success, which will mislead the callers. >> Wrap to fit in 75 columns, add "()" after function names. >>> Signed-off-by: zhangjianrong <zhangjianrong5@huawei.com> >>> Signed-off-by: zhangjiantao <water.zhangjiantao@huawei.com> >>> >>> --- >>> drivers/pci/controller/dwc/pcie-designware-host.c | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c >>> b/drivers/pci/controller/dwc/pcie-designware-host.c >>> index f4755f3a03be..ac691d733848 100644 >>> --- a/drivers/pci/controller/dwc/pcie-designware-host.c >>> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c >>> @@ -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). >> >>> goto err_free_msi; >>> } >>> } >>> -- >>> 2.17.1 >>> >> . ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PCI: dwc: Fix setting error return on MSI DMA mapping failure 2022-03-09 12:01 ` [PATCH v2] PCI: dwc: Fix setting error return on MSI DMA mapping failure Jiantao Zhang @ 2022-03-24 21:04 ` Rob Herring 2022-04-08 14:43 ` Lorenzo Pieralisi 1 sibling, 0 replies; 5+ messages in thread From: Rob Herring @ 2022-03-24 21:04 UTC (permalink / raw) To: Jiantao Zhang Cc: Bjorn Helgaas, jingoohan1, gustavo.pimentel, lorenzo.pieralisi, kw, linux-pci, linux-kernel, zhangjianrong (E), caiyadong, xuetao (kirin), xuhaiyang, songxiaowei, guhengsheng On Wed, Mar 09, 2022 at 08:01:04PM +0800, Jiantao Zhang wrote: > When dma_mapping_error() returns error because of no enough memory, > but dw_pcie_host_init() returns success, which will mislead the callers. > > Fixes: 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume") > Signed-off-by: Jianrong Zhang <zhangjianrong5@huawei.com> > Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com> > --- > drivers/pci/controller/dwc/pcie-designware-host.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PCI: dwc: Fix setting error return on MSI DMA mapping failure 2022-03-09 12:01 ` [PATCH v2] PCI: dwc: Fix setting error return on MSI DMA mapping failure Jiantao Zhang 2022-03-24 21:04 ` Rob Herring @ 2022-04-08 14:43 ` Lorenzo Pieralisi 1 sibling, 0 replies; 5+ messages in thread From: Lorenzo Pieralisi @ 2022-04-08 14:43 UTC (permalink / raw) To: gustavo.pimentel, jingoohan1, robh, Bjorn Helgaas, Jiantao Zhang, zhangjianrong (E), linux-pci, linux-kernel, kw Cc: Lorenzo Pieralisi, xuhaiyang, guhengsheng, songxiaowei, xuetao (kirin), caiyadong On Wed, 9 Mar 2022 20:01:04 +0800, Jiantao Zhang wrote: > When dma_mapping_error() returns error because of no enough memory, > but dw_pcie_host_init() returns success, which will mislead the callers. > > Applied to pci/dwc, thanks! [1/1] PCI: dwc: Fix setting error return on MSI DMA mapping failure https://git.kernel.org/lpieralisi/pci/c/88557685cd Thanks, Lorenzo ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-08 14:44 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-08 15:45 [PATCH2] PCI: dwc: solve returning success but actually failed Zhangjiantao(Kirin,Nanjing) 2022-03-08 17:03 ` Rob Herring 2022-03-09 12:01 ` [PATCH v2] PCI: dwc: Fix setting error return on MSI DMA mapping failure Jiantao Zhang 2022-03-24 21:04 ` Rob Herring 2022-04-08 14:43 ` Lorenzo Pieralisi
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).