From: Bjorn Helgaas Date: Fri, 5 Nov 2021 16:28:46 +0000 (-0500) Subject: Merge branch 'pci/sysfs' X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ebf275b8564ccc3a75a3ee8f9167a4a20794f050;p=linux.git 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 --- ebf275b8564ccc3a75a3ee8f9167a4a20794f050 diff --cc drivers/pci/iov.c index fa4b52bb1e055,0267977c9f178..1d7a7c5b53078 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.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); + 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; @@@ -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); + 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;