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: <245c1063-f0cf-551a-b93c-1a0a5ac06eff@huawei.com>
Date:   Sun, 21 Mar 2021 23:51:41 +0800
From:   Zhiqiang Liu <liuzhiqiang26@...wei.com>
To:     <schnelle@...ux.ibm.com>, <gerald.schaefer@...ux.ibm.com>,
        <bhelgaas@...gle.com>
CC:     <linux-s390@...r.kernel.org>, <linux-pci@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        linfeilong <linfeilong@...wei.com>, <liuzhiqiang26@...wei.com>
Subject: [PATCH] pci/hotplug: fix potential memory leak in disable_slot()


In disable_slot(), if we obtain desired PCI device
successfully by calling pci_get_slot(), we should
call pci_dev_put() to release its reference.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com>
Signed-off-by: Feilong Lin <linfeilong@...wei.com>
---
 drivers/pci/hotplug/s390_pci_hpc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c
index c9e790c74051..999a34b6fd50 100644
--- a/drivers/pci/hotplug/s390_pci_hpc.c
+++ b/drivers/pci/hotplug/s390_pci_hpc.c
@@ -89,9 +89,11 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
 		return -EIO;

 	pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
-	if (pdev && pci_num_vf(pdev)) {
+	if (pdev) {
+		rc = pci_num_vf(pdev);
 		pci_dev_put(pdev);
-		return -EBUSY;
+		if (rc)
+			return -EBUSY;
 	}

 	zpci_remove_device(zdev);
-- 
2.19.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ