lkml.org 
[lkml]   [2021]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] pci/hotplug: fix potential memory leak in disable_slot()
Date

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@huawei.com>
Signed-off-by: Feilong Lin <linfeilong@huawei.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

\
 
 \ /
  Last update: 2021-03-21 16:53    [W:0.025 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site