mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
PCI/sysfs: Stop reporting _DSM failures as -EPERM
Currently, dsm_get_label() returns the literal -1 on every failure path.
The sysfs read path passes that value to userspace as -EPERM. Reading the
"label" or "acpi_index" attribute on a platform where the Device Name _DSM
returns a malformed result then fails with:
$ cat /sys/bus/pci/devices/0000:00:08.3/label
cat: /sys/bus/pci/devices/0000:00:08.3/label: Operation not permitted
Nothing in that path performs a permission check, and the read fails the
same way for a privileged reader. The error code points at a cause that
does not exist, and tools such as lspci report it on every invocation.
Return -ENODEV when the device has no ACPI companion, and -EIO when the
_DSM evaluation fails or returns an object that cannot be parsed. Other
_DSM users in the tree report such failures the same way.
The set of reads that succeed, and the bytes they return, stay the same.
Only the error code of reads that already fail differs.
Fixes: 6058989bad ("PCI: Export ACPI _DSM provided firmware instance number and string name to sysfs")
Link: https://github.com/pciutils/pciutils/issues/175
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260814070522.2327975-2-kwilczynski@kernel.org
This commit is contained in:
parent
cee9395acd
commit
36f9bd0992
|
|
@ -160,12 +160,12 @@ static int dsm_get_label(struct device *dev, char *buf,
|
|||
int len = 0;
|
||||
|
||||
if (!handle)
|
||||
return -1;
|
||||
return -ENODEV;
|
||||
|
||||
obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 0x2,
|
||||
DSM_PCI_DEVICE_NAME, NULL);
|
||||
if (!obj)
|
||||
return -1;
|
||||
return -EIO;
|
||||
|
||||
tmp = obj->package.elements;
|
||||
if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
|
||||
|
|
@ -190,7 +190,7 @@ static int dsm_get_label(struct device *dev, char *buf,
|
|||
|
||||
ACPI_FREE(obj);
|
||||
|
||||
return len > 0 ? len : -1;
|
||||
return len > 0 ? len : -EIO;
|
||||
}
|
||||
|
||||
static ssize_t label_show(struct device *dev, struct device_attribute *attr,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user