summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2020-03-29 01:11:07 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2020-03-29 01:11:07 +0100
commitca1b073bc058d3cd1a8ba152ef5a39d0a78a9e0e (patch)
tree03bb502abb650f16fede58a5d19c91c410613c98
parent96a9f67a8685e713f25259c18306797d54cc27a5 (diff)
pci-arbiter: Fix short reads from libpciaccess
* pci-arbiter/pci-ops.c (S_pci_conf_read): Record and pass amount actually read from config memory. (S_pci_conf_write): Likewise for write.
-rw-r--r--pci-arbiter/pci-ops.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/pci-arbiter/pci-ops.c b/pci-arbiter/pci-ops.c
index 8279540a3..19aee71db 100644
--- a/pci-arbiter/pci-ops.c
+++ b/pci-arbiter/pci-ops.c
@@ -85,6 +85,7 @@ S_pci_conf_read (struct protid * master, int reg, char **data,
error_t err;
pthread_mutex_t *lock;
struct pcifs_dirent *e;
+ size_t actual_len;
if (!master)
return EOPNOTSUPP;
@@ -112,12 +113,12 @@ S_pci_conf_read (struct protid * master, int reg, char **data,
* libnetfs which is multi-threaded. A lock is needed for arbitration.
*/
pthread_mutex_lock (lock);
- err = pci_device_cfg_read (e->device, *data, reg, amount, NULL);
+ err = pci_device_cfg_read (e->device, *data, reg, amount, &actual_len);
pthread_mutex_unlock (lock);
if (!err)
{
- *datalen = amount;
+ *datalen = actual_len;
/* Update atime */
UPDATE_TIMES (e, TOUCH_ATIME);
}
@@ -133,6 +134,7 @@ S_pci_conf_write (struct protid * master, int reg, char *data, size_t datalen,
error_t err;
pthread_mutex_t *lock;
struct pcifs_dirent *e;
+ size_t actual_len;
if (!master)
return EOPNOTSUPP;
@@ -149,12 +151,12 @@ S_pci_conf_write (struct protid * master, int reg, char *data, size_t datalen,
return err;
pthread_mutex_lock (lock);
- err = pci_device_cfg_write (e->device, data, reg, datalen, NULL);
+ err = pci_device_cfg_write (e->device, data, reg, datalen, &actual_len);
pthread_mutex_unlock (lock);
if (!err)
{
- *amount = datalen;
+ *amount = actual_len;
/* Update mtime and ctime */
UPDATE_TIMES (e, TOUCH_MTIME | TOUCH_CTIME);
}