aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-03-04 16:44:26 +0100
committerFlorin Coras <florin.coras@gmail.com>2018-03-04 18:00:03 +0000
commit44bcc20fcfaa572f500c8acf1b94dda7d3f5151c (patch)
treeb4d3c004084d9f83f4fd12df6a6c4aef21a5a311
parent7b185360843c2b1cbcbeede64340add8a56fe440 (diff)
vlib: fix vlib_pci_get_device_info on when not running as root
While comment properly says that only first 64 bytes can be read, actual code was returning error instead being happy with 64 bytes received. Change-Id: I09c0d1d5c9fc8e1f6c59c093d81bb1ce1924281b Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--src/vlib/linux/pci.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c
index 8954bccd93f..e67e651d9a8 100644
--- a/src/vlib/linux/pci.c
+++ b/src/vlib/linux/pci.c
@@ -182,10 +182,8 @@ vlib_pci_get_device_info (vlib_pci_addr_t * addr, clib_error_t ** error)
/* You can only read more that 64 bytes of config space as root; so we try to
read the full space but fall back to just the first 64 bytes. */
- if (read (fd, &di->config_data, sizeof (di->config_data)) !=
- sizeof (di->config_data)
- && read (fd, &di->config0,
- sizeof (di->config0)) != sizeof (di->config0))
+ if (read (fd, &di->config_data, sizeof (di->config_data)) <
+ sizeof (di->config0))
{
err = clib_error_return_unix (0, "read `%s'", f);
close (fd);