* [dpdk-dev] [PATCH] virtio: fix PCI config err handling
@ 2017-06-05 15:44 Brian Russell
2017-06-12 10:31 ` Yuanhan Liu
0 siblings, 1 reply; 2+ messages in thread
From: Brian Russell @ 2017-06-05 15:44 UTC (permalink / raw)
To: Yuanhan Liu, Maxime Coquelin; +Cc: dev
In virtio_read_caps, rte_pci_read_config returns the number of bytes
read from PCI config or <0 on error.
If less than the expected number of bytes are read then log the
failure and return rather than carrying on with garbage.
Signed-off-by: Brian Russell <brussell@brocade.com>
---
drivers/net/virtio/virtio_pci.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index b7b3d61..90c098e 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -592,16 +592,18 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw)
}
ret = rte_pci_read_config(dev, &pos, 1, PCI_CAPABILITY_LIST);
- if (ret < 0) {
- PMD_INIT_LOG(DEBUG, "failed to read pci capability list");
+ if (ret != 1) {
+ PMD_INIT_LOG(DEBUG,
+ "failed to read pci capability list, ret %d", ret);
return -1;
}
while (pos) {
ret = rte_pci_read_config(dev, &cap, sizeof(cap), pos);
- if (ret < 0) {
- PMD_INIT_LOG(ERR,
- "failed to read pci cap at pos: %x", pos);
+ if (ret != sizeof(cap)) {
+ PMD_INIT_LOG(DEBUG,
+ "failed to read pci cap at pos: %x ret %d",
+ pos, ret);
break;
}
--
2.1.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] virtio: fix PCI config err handling
2017-06-05 15:44 [dpdk-dev] [PATCH] virtio: fix PCI config err handling Brian Russell
@ 2017-06-12 10:31 ` Yuanhan Liu
0 siblings, 0 replies; 2+ messages in thread
From: Yuanhan Liu @ 2017-06-12 10:31 UTC (permalink / raw)
To: Brian Russell; +Cc: Maxime Coquelin, dev
On Mon, Jun 05, 2017 at 04:44:33PM +0100, Brian Russell wrote:
> In virtio_read_caps, rte_pci_read_config returns the number of bytes
> read from PCI config or <0 on error.
> If less than the expected number of bytes are read then log the
> failure and return rather than carrying on with garbage.
>
> Signed-off-by: Brian Russell <brussell@brocade.com>
> ---
> drivers/net/virtio/virtio_pci.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
> index b7b3d61..90c098e 100644
> --- a/drivers/net/virtio/virtio_pci.c
> +++ b/drivers/net/virtio/virtio_pci.c
> @@ -592,16 +592,18 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw)
> }
>
> ret = rte_pci_read_config(dev, &pos, 1, PCI_CAPABILITY_LIST);
> - if (ret < 0) {
> - PMD_INIT_LOG(DEBUG, "failed to read pci capability list");
> + if (ret != 1) {
> + PMD_INIT_LOG(DEBUG,
> + "failed to read pci capability list, ret %d", ret);
> return -1;
> }
There are two things worth mentioning:
- rte_pci.h states nothing about the return value
- The BSD implementation actually returns 0 on success, while the Linux
implementation indeed returns the bytes read.
--yliu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-12 10:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 15:44 [dpdk-dev] [PATCH] virtio: fix PCI config err handling Brian Russell
2017-06-12 10:31 ` Yuanhan Liu
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).