s390/pci: Fix duplicate pci_dev_put() in disable_slot() when PF has child VFs
authorNiklas Schnelle <schnelle@linux.ibm.com>
Wed, 30 Apr 2025 13:26:19 +0000 (15:26 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Wed, 7 May 2025 11:35:05 +0000 (13:35 +0200)
With commit bcb5d6c76903 ("s390/pci: introduce lock to synchronize state
of zpci_dev's") the code to ignore power off of a PF that has child VFs
was changed from a direct return to a goto to the unlock and
pci_dev_put() section. The change however left the existing pci_dev_put()
untouched resulting in a doubple put. This can subsequently cause a use
after free if the struct pci_dev is released in an unexpected state.
Fix this by removing the extra pci_dev_put().

Cc: stable@vger.kernel.org
Fixes: bcb5d6c76903 ("s390/pci: introduce lock to synchronize state of zpci_dev's")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Gerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/pci/hotplug/s390_pci_hpc.c

index 055518e..e9e9aaa 100644 (file)
@@ -59,7 +59,6 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
 
        pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
        if (pdev && pci_num_vf(pdev)) {
-               pci_dev_put(pdev);
                rc = -EBUSY;
                goto out;
        }