From: Vasundhara Volam <vasundhara.volam@xxxxxxxxxx> A user must not be allowed to disable VFs while they are already assigned to a guest. This check is being made in each individual driver that implements the sriov_configure PCI method. This patch fixes this code duplication by moving this check to the sriov_nuvfs_store() routine just before invoking sriov_configure() when num_vfs is equal to 0. Signed-off-by: Vasundhara Volam <vasundhara.volam@xxxxxxxxxx> Signed-off-by: Sathya Perla <sathya.perla@xxxxxxxxxx> --- drivers/pci/pci-sysfs.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 2c6643f..6e65b47 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -477,6 +477,11 @@ static ssize_t sriov_numvfs_store(struct device *dev, } if (num_vfs == 0) { + if (pci_vfs_assigned(pdev)) { + dev_warn(&pdev->dev, "Cannot disable VFs while they are assigned\n"); + return -EBUSY; + } + /* disable VFs */ ret = pdev->driver->sriov_configure(pdev, 0); if (ret < 0) -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html