Re: [PATCH] fix: PCI: pci_iov_remove_virtfn: fix unmatched pci_dev_put for PF device

From: WenTao Liang

Date: Sun Jun 28 2026 - 00:01:40 EST




> 2026年6月26日 23:50,WenTao Liang <vulab@xxxxxxxxxxx> 写道:
>
> 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)

Please ignore this patch. I will resend a proper version after
learning the kernel submission process.

Apologies for the noise.

Best regards,
WenTao Liang