aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/iov.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2021-11-05 11:28:46 -0500
committerBjorn Helgaas <bhelgaas@google.com>2021-11-05 11:28:46 -0500
commitebf275b8564ccc3a75a3ee8f9167a4a20794f050 (patch)
tree392fff6b7aec124c5f41086600d76d136d604157 /drivers/pci/iov.c
parentMerge branch 'pci/switchtec' (diff)
parentPCI: Use kstrtobool() directly, sans strtobool() wrapper (diff)
downloadlinux-dev-ebf275b8564ccc3a75a3ee8f9167a4a20794f050.tar.xz
linux-dev-ebf275b8564ccc3a75a3ee8f9167a4a20794f050.zip
Merge branch 'pci/sysfs'
- Check for CAP_SYS_ADMIN before validating sysfs user input, not after (Krzysztof Wilczyński) - Always return -EINVAL from sysfs "store" functions for invalid user input instead of -EINVAL sometimes and -ERANGE others (Krzysztof Wilczyński) - Use kstrtobool() directly instead of the strtobool() wrapper (Krzysztof Wilczyński) * pci/sysfs: PCI: Use kstrtobool() directly, sans strtobool() wrapper PCI/sysfs: Return -EINVAL consistently from "store" functions PCI/sysfs: Check CAP_SYS_ADMIN before parsing user input # Conflicts: # drivers/pci/iov.c
Diffstat (limited to 'drivers/pci/iov.c')
-rw-r--r--drivers/pci/iov.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index fa4b52bb1e05..1d7a7c5b5307 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -186,11 +186,10 @@ static ssize_t sriov_vf_msix_count_store(struct device *dev,
struct pci_dev *vf_dev = to_pci_dev(dev);
struct pci_dev *pdev = pci_physfn(vf_dev);
struct pci_driver *pdrv;
- int val, ret;
+ int val, ret = 0;
- ret = kstrtoint(buf, 0, &val);
- if (ret)
- return ret;
+ if (kstrtoint(buf, 0, &val) < 0)
+ return -EINVAL;
if (val < 0)
return -EINVAL;
@@ -381,12 +380,11 @@ static ssize_t sriov_numvfs_store(struct device *dev,
{
struct pci_dev *pdev = to_pci_dev(dev);
struct pci_driver *pdrv;
- int ret;
+ int ret = 0;
u16 num_vfs;
- ret = kstrtou16(buf, 0, &num_vfs);
- if (ret < 0)
- return ret;
+ if (kstrtou16(buf, 0, &num_vfs) < 0)
+ return -EINVAL;
if (num_vfs > pci_sriov_get_totalvfs(pdev))
return -ERANGE;