diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2021-11-05 17:28:46 +0100 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2021-11-05 17:28:46 +0100 |
commit | ebf275b8564ccc3a75a3ee8f9167a4a20794f050 (patch) | |
tree | 392fff6b7aec124c5f41086600d76d136d604157 /drivers/pci/iov.c | |
parent | Merge branch 'pci/switchtec' (diff) | |
parent | PCI: Use kstrtobool() directly, sans strtobool() wrapper (diff) | |
download | linux-ebf275b8564ccc3a75a3ee8f9167a4a20794f050.tar.xz linux-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.c | 14 |
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; |