Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 156c5532 authored by Po Liu's avatar Po Liu Committed by Bjorn Helgaas
Browse files

PCI: Check for pci_setup_device() failure in pci_iov_add_virtfn()



If pci_setup_device() returns failure, we must return failure from
pci_iov_add_virtfn().  If we ignore the failure and continue with an
uninitialized pci_dev for virtfn, we crash later when we try to use those
uninitialized parts.

Signed-off-by: default avatarPo Liu <po.liu@nxp.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 8e2e0317
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -136,7 +136,10 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id, int reset)
	virtfn->devfn = pci_iov_virtfn_devfn(dev, id);
	virtfn->vendor = dev->vendor;
	pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device);
	pci_setup_device(virtfn);
	rc = pci_setup_device(virtfn);
	if (rc)
		goto failed0;

	virtfn->dev.parent = dev->dev.parent;
	virtfn->physfn = pci_dev_get(dev);
	virtfn->is_virtfn = 1;