Thread (16 messages) 16 messages, 5 authors, 2021-10-28

Re: [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any()

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: 2021-10-13 18:09:14
Also in: linux-pci

On 13.10.2021 16:22, Qian Cai wrote:

On 10/12/2021 4:26 PM, Heiner Kallweit wrote:
quoted
Thanks for the report! I could reproduce the issue, the following fixes
it for me. Could you please test whether it fixes the issue for you as well?
Yes, it works fine. BTW, in the original patch here:
Thanks for testing!
quoted hunk ↗ jump to hunk
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -138,9 +138,10 @@ static int pci_vpd_wait(struct pci_dev *dev, bool set)
 }
 
 static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
-			    void *arg)
+			    void *arg, bool check_size)
 {
 	struct pci_vpd *vpd = &dev->vpd;
+	unsigned int max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
 	int ret = 0;
 	loff_t end = pos + count;
 	u8 *buf = arg;
@@ -151,11 +152,11 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
 	if (pos < 0)
 		return -EINVAL;
 
-	if (pos > vpd->len)
+	if (pos >= max_len)
 		return 0;
I am not sure if "pos >= max_len" is correct there, so just want to give you
a chance to double-check.
This is intentional, but good catch.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help