[dpdk-dev,v3] net/virtio-user: fix unchecked return value

Message ID 1510655996-39288-1-git-send-email-sebastianx.basierski@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Yuanhan Liu
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

SebastianX Basierski Nov. 14, 2017, 10:39 a.m. UTC
  Report error message if clearing O_NONBLOCK flag will fail,
then return from function.

Coverity issue: 143439

Fixes: ef53b6030039 ("net/virtio-user: support LSC")
Cc: jianfeng.tan@intel.com
Cc: yliu@fridaylinux.org
cc: dev@dpdk.org

Signed-off-by: SebastianX Basierski <sebastianx.basierski@intel.com>
Acked-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
v2:
        Patch title changed.
---
 drivers/net/virtio/virtio_user_ethdev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Feb. 6, 2018, 8:48 p.m. UTC | #1
14/11/2017 11:39, SebastianX Basierski:
> Report error message if clearing O_NONBLOCK flag will fail,
> then return from function.
> 
> Coverity issue: 143439
> 
> Fixes: ef53b6030039 ("net/virtio-user: support LSC")
> Cc: jianfeng.tan@intel.com
> Cc: yliu@fridaylinux.org
> cc: dev@dpdk.org
> 
> Signed-off-by: SebastianX Basierski <sebastianx.basierski@intel.com>
> Acked-by: Jianfeng Tan <jianfeng.tan@intel.com>
> Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>

I don't know why this patch was forgotten in the virtio tree.

Applied, thanks
  

Patch

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 7be57ce..c1f7a64 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -109,7 +109,11 @@  virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
 			} else {
 				dev->status |= VIRTIO_NET_S_LINK_UP;
 			}
-			fcntl(dev->vhostfd, F_SETFL, flags & (~O_NONBLOCK));
+			if (fcntl(dev->vhostfd, F_SETFL,
+					flags & ~O_NONBLOCK) == -1) {
+				PMD_DRV_LOG(ERR, "error clearing O_NONBLOCK flag");
+				return;
+			}
 		}
 		*(uint16_t *)dst = dev->status;
 	}