Skip to content

Commit 5479a7f

Browse files
committed
Merge tag 's390-5.14-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fix from Vasily Gorbik: - fix use after free of zpci_dev in pci code * tag 's390-5.14-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/pci: fix use after free of zpci_dev
2 parents 15517c7 + 2a671f7 commit 5479a7f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

arch/s390/pci/pci.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,12 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev)
560560

561561
int pcibios_add_device(struct pci_dev *pdev)
562562
{
563+
struct zpci_dev *zdev = to_zpci(pdev);
563564
struct resource *res;
564565
int i;
565566

567+
/* The pdev has a reference to the zdev via its bus */
568+
zpci_zdev_get(zdev);
566569
if (pdev->is_physfn)
567570
pdev->no_vf_scan = 1;
568571

@@ -582,7 +585,10 @@ int pcibios_add_device(struct pci_dev *pdev)
582585

583586
void pcibios_release_device(struct pci_dev *pdev)
584587
{
588+
struct zpci_dev *zdev = to_zpci(pdev);
589+
585590
zpci_unmap_resources(pdev);
591+
zpci_zdev_put(zdev);
586592
}
587593

588594
int pcibios_enable_device(struct pci_dev *pdev, int mask)

arch/s390/pci/pci_bus.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ static inline void zpci_zdev_put(struct zpci_dev *zdev)
2222
kref_put(&zdev->kref, zpci_release_device);
2323
}
2424

25+
static inline void zpci_zdev_get(struct zpci_dev *zdev)
26+
{
27+
kref_get(&zdev->kref);
28+
}
29+
2530
int zpci_alloc_domain(int domain);
2631
void zpci_free_domain(int domain);
2732
int zpci_setup_bus_resources(struct zpci_dev *zdev,

0 commit comments

Comments
 (0)