Merge branch 'pci/sysfs'
authorBjorn Helgaas <bhelgaas@google.com>
Fri, 5 Nov 2021 16:28:46 +0000 (11:28 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 5 Nov 2021 16:28:46 +0000 (11:28 -0500)
- 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

1  2 
drivers/pci/iov.c
drivers/pci/p2pdma.c
drivers/pci/pci-sysfs.c

@@@ -185,12 -183,10 +185,11 @@@ static ssize_t sriov_vf_msix_count_stor
  {
        struct pci_dev *vf_dev = to_pci_dev(dev);
        struct pci_dev *pdev = pci_physfn(vf_dev);
-       int val, ret;
 +      struct pci_driver *pdrv;
+       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;
@@@ -380,13 -375,11 +379,12 @@@ static ssize_t sriov_numvfs_store(struc
                                  const char *buf, size_t count)
  {
        struct pci_dev *pdev = to_pci_dev(dev);
-       int ret;
 +      struct pci_driver *pdrv;
+       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;
Simple merge
Simple merge