[PATCH] fix: PCI: pci_iov_remove_virtfn: fix unmatched pci_dev_put for PF device
From: WenTao Liang
Date: Fri Jun 26 2026 - 11:55:05 EST
In pci_iov_remove_virtfn(), the function calls pci_dev_put(dev) on the PF
device at the end, but never acquired a reference to it via
pci_dev_get(). The function parameter dev is passed by the caller who
manages the reference. This unbalanced pci_dev_put causes a refcount
underflow, potentially leading to premature PF device release or
use-after-free.
Remove the spurious pci_dev_put(dev) call.
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
---
drivers/pci/iov.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 91ac4e37ecb9..24a4fb3cd042 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -426,7 +426,6 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id)
/* balance pci_get_domain_bus_and_slot() */
pci_dev_put(virtfn);
- pci_dev_put(dev);
}
static ssize_t sriov_totalvfs_show(struct device *dev,
--
2.39.5 (Apple Git-154)