Commit f52e5629 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Bjorn Helgaas

PCI: Allow access to VPD attributes with size 0

It is not always possible to determine the actual size of the VPD
data, so allow access to them if the size is set to '0'.
Tested-by: default avatarShane Seymour <shane.seymour@hpe.com>
Tested-by: default avatarBabu Moger <babu.moger@oracle.com>
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
parent 9eb45d5c
...@@ -769,10 +769,12 @@ static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj, ...@@ -769,10 +769,12 @@ static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj,
{ {
struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
if (off > bin_attr->size) if (bin_attr->size > 0) {
count = 0; if (off > bin_attr->size)
else if (count > bin_attr->size - off) count = 0;
count = bin_attr->size - off; else if (count > bin_attr->size - off)
count = bin_attr->size - off;
}
return pci_read_vpd(dev, off, count, buf); return pci_read_vpd(dev, off, count, buf);
} }
...@@ -783,10 +785,12 @@ static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj, ...@@ -783,10 +785,12 @@ static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj,
{ {
struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
if (off > bin_attr->size) if (bin_attr->size > 0) {
count = 0; if (off > bin_attr->size)
else if (count > bin_attr->size - off) count = 0;
count = bin_attr->size - off; else if (count > bin_attr->size - off)
count = bin_attr->size - off;
}
return pci_write_vpd(dev, off, count, buf); return pci_write_vpd(dev, off, count, buf);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment