lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <0dcdea9c559040509dd443ee75de75a1@huawei.com>
Date:   Tue, 8 Mar 2022 15:45:45 +0000
From:   "Zhangjiantao(Kirin,Nanjing)" <water.zhangjiantao@...wei.com>
To:     Bjorn Helgaas <helgaas@...nel.org>,
        "robh@...nel.org" <robh@...nel.org>
CC:     "jingoohan1@...il.com" <jingoohan1@...il.com>,
        "gustavo.pimentel@...opsys.com" <gustavo.pimentel@...opsys.com>,
        "lorenzo.pieralisi@....com" <lorenzo.pieralisi@....com>,
        "kw@...ux.com" <kw@...ux.com>,
        "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "zhangjianrong (E)" <zhangjianrong5@...wei.com>
Subject: [PATCH2] 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.

Fixes: 07940c369a6b ("PCI: dwc: Fix MSI page leakage in suspend/resume")

Signed-off-by: Jiantao Zhang <water.zhangjiantao@...wei.com>
Signed-off-by: Jianrong Zhang <zhangjianrong5@...wei.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@...wei.com>
>> Signed-off-by: zhangjiantao <water.zhangjiantao@...wei.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
>>
> .

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ