* [PATCH] PCI/IOV: Drop device reference on sriov_init() failure
@ 2026-06-22 9:31 Haoxiang Li
2026-06-22 9:40 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-06-22 9:31 UTC (permalink / raw)
To: bhelgaas, aduyck; +Cc: linux-pci, linux-kernel, Haoxiang Li, stable
sriov_init() takes a reference to another PF device with pci_dev_get()
when an existing PF is found on the bus. If compute_max_vf_buses() fails
afterwards, the error path clears dev->sriov and frees the pci_sriov
structure, but does not drop that reference.
Release iov->dev before freeing iov on the error path, matching the
cleanup done by sriov_release().
Fixes: ea9a8854161d ("PCI: Set SR-IOV NumVFs to zero after enumeration")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
drivers/pci/iov.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 91ac4e37ecb9..1a55863fa7a0 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -905,6 +905,8 @@ static int sriov_init(struct pci_dev *dev, int pos)
return 0;
fail_max_buses:
+ if (iov->dev != dev)
+ pci_dev_put(iov->dev);
dev->sriov = NULL;
dev->is_physfn = 0;
failed:
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-22 9:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 9:31 [PATCH] PCI/IOV: Drop device reference on sriov_init() failure Haoxiang Li
2026-06-22 9:40 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.