PCI: Fix sriov_enable() error path for pcibios_enable_sriov() failures
authorAlexander Duyck <aduyck@mirantis.com>
Thu, 29 Oct 2015 21:21:20 +0000 (16:21 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 30 Oct 2015 20:15:02 +0000 (15:15 -0500)
Disable VFs if pcibios_enable_sriov() fails, just like we do for other
errors in sriov_enable().  Call pcibios_sriov_disable() if virtfn_add()
fails.

[bhelgaas: changelog, split to separate patch for reviewability]
Fixes: 995df527f399 ("PCI: Add pcibios_sriov_enable() and pcibios_sriov_disable()")
Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Wei Yang <weiyang@linux.vnet.ibm.com>
drivers/pci/iov.c

index 24428d5f60cd6cd36b15af9de38bf21db18450ac..bd1c4faedea2acc83a6ba3323807ab2fbab864cf 100644 (file)
@@ -246,7 +246,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
        struct pci_sriov *iov = dev->sriov;
        int bars = 0;
        int bus;
-       int retval;
 
        if (!nr_virtfn)
                return 0;
@@ -315,10 +314,10 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
        if (nr_virtfn < initial)
                initial = nr_virtfn;
 
-       if ((retval = pcibios_sriov_enable(dev, initial))) {
-               dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n",
-                       retval);
-               return retval;
+       rc = pcibios_sriov_enable(dev, initial);
+       if (rc) {
+               dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", rc);
+               goto err_pcibios;
        }
 
        for (i = 0; i < initial; i++) {
@@ -336,6 +335,8 @@ failed:
        while (i--)
                virtfn_remove(dev, i, 0);
 
+       pcibios_sriov_disable(dev);
+err_pcibios:
        iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE);
        pci_cfg_access_lock(dev);
        pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
This page took 0.026461 seconds and 5 git commands to generate.