From: Hannes Reinecke <hare@suse.de>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>,
linux-pci@vger.kernel.org, Babu Moger <babu.moger@oracle.com>,
Jordan Hargrave <Jordan_Hargrave@dell.com>,
Hannes Reinecke <hare@suse.de>
Subject: [PATCHv3 2/4] pci: allow access to VPD attributes with size '0'
Date: Mon, 15 Feb 2016 09:42:00 +0100 [thread overview]
Message-ID: <1455525722-122040-3-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1455525722-122040-1-git-send-email-hare@suse.de>
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'.
Cc: Alexander Duyck <alexander.duyck@gmail.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/pci/pci-sysfs.c | 20 ++++++++++++--------
1 file 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);
}
--
1.8.5.6
next prev parent reply other threads:[~2016-02-15 8:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 8:41 [PATCHv3 0/4] PCI VPD access fixes Hannes Reinecke
2016-02-15 8:41 ` [PATCHv3 1/4] pci: Update VPD definitions Hannes Reinecke
2016-02-15 8:42 ` Hannes Reinecke [this message]
2016-02-15 8:42 ` [PATCHv3 3/4] pci: Determine actual VPD size on first access Hannes Reinecke
2016-02-15 8:42 ` [PATCHv3 4/4] pci: Blacklist vpd access for buggy devices Hannes Reinecke
2016-02-22 19:57 ` Bjorn Helgaas
2016-02-16 23:50 ` [PATCHv3 0/4] PCI VPD access fixes Seymour, Shane M
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455525722-122040-3-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=Jordan_Hargrave@dell.com \
--cc=alexander.duyck@gmail.com \
--cc=babu.moger@oracle.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).