From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
To: <schnelle@linux.ibm.com>, <gerald.schaefer@linux.ibm.com>,
<bhelgaas@google.com>
Cc: <linux-s390@vger.kernel.org>, <linux-pci@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linfeilong <linfeilong@huawei.com>, <liuzhiqiang26@huawei.com>
Subject: [PATCH] pci/hotplug: fix potential memory leak in disable_slot()
Date: Sun, 21 Mar 2021 23:51:41 +0800 [thread overview]
Message-ID: <245c1063-f0cf-551a-b93c-1a0a5ac06eff@huawei.com> (raw)
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
next reply other threads:[~2021-03-21 15:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 15:51 Zhiqiang Liu [this message]
2021-03-22 9:42 ` Niklas Schnelle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=245c1063-f0cf-551a-b93c-1a0a5ac06eff@huawei.com \
--to=liuzhiqiang26@huawei.com \
--cc=bhelgaas@google.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=linfeilong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=schnelle@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®