diff options
author | Hannes Reinecke <hare@suse.de> | 2016-02-15 09:42:00 +0100 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2016-02-29 17:46:50 -0600 |
commit | f52e5629f66d5fd79ae8b8145d76ae0ddb47e142 (patch) | |
tree | fd7942e21ef8299161bd2ceec0be35db58e72b96 /drivers/pci/pci-sysfs.c | |
parent | 9eb45d5cc541142896f5fe7896d824c1091197c9 (diff) | |
download | op-kernel-dev-f52e5629f66d5fd79ae8b8145d76ae0ddb47e142.zip op-kernel-dev-f52e5629f66d5fd79ae8b8145d76ae0ddb47e142.tar.gz |
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: Shane Seymour <shane.seymour@hpe.com>
Tested-by: Babu Moger <babu.moger@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 95d9e7b..a730f54 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -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)); - if (off > bin_attr->size) - count = 0; - else if (count > bin_attr->size - off) - count = bin_attr->size - off; + if (bin_attr->size > 0) { + if (off > bin_attr->size) + count = 0; + else if (count > bin_attr->size - off) + count = bin_attr->size - off; + } return pci_read_vpd(dev, off, count, buf); } @@ -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)); - if (off > bin_attr->size) - count = 0; - else if (count > bin_attr->size - off) - count = bin_attr->size - off; + if (bin_attr->size > 0) { + if (off > bin_attr->size) + count = 0; + else if (count > bin_attr->size - off) + count = bin_attr->size - off; + } return pci_write_vpd(dev, off, count, buf); } |