diff options
| author | Po Liu <po.liu@nxp.com> | 2016-08-29 03:28:01 -0400 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2016-09-12 17:23:38 -0400 |
| commit | 156c55325d30261d250e88ed3a39f22008f4ca16 (patch) | |
| tree | 2a9d74672916907e1ebd627a731fd0609aeaba39 | |
| parent | 8e2e03179923479ca0c0b6fdc7c93ecf89bce7a8 (diff) | |
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: Po Liu <po.liu@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
| -rw-r--r-- | drivers/pci/iov.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 2194b447201d..e30f05c8517f 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
| @@ -136,7 +136,10 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id, int reset) | |||
| 136 | virtfn->devfn = pci_iov_virtfn_devfn(dev, id); | 136 | virtfn->devfn = pci_iov_virtfn_devfn(dev, id); |
| 137 | virtfn->vendor = dev->vendor; | 137 | virtfn->vendor = dev->vendor; |
| 138 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); | 138 | pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); |
| 139 | pci_setup_device(virtfn); | 139 | rc = pci_setup_device(virtfn); |
| 140 | if (rc) | ||
| 141 | goto failed0; | ||
| 142 | |||
| 140 | virtfn->dev.parent = dev->dev.parent; | 143 | virtfn->dev.parent = dev->dev.parent; |
| 141 | virtfn->physfn = pci_dev_get(dev); | 144 | virtfn->physfn = pci_dev_get(dev); |
| 142 | virtfn->is_virtfn = 1; | 145 | virtfn->is_virtfn = 1; |
