net/virtio: check error on setting non block flag
authorSebastian Basierski <sebastianx.basierski@intel.com>
Tue, 24 Oct 2017 08:17:38 +0000 (10:17 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 24 Oct 2017 19:29:47 +0000 (21:29 +0200)
Report an error message if the flag O_NONBLOCK setting fails,
then return from function.

Coverity issue: 143439
Fixes: ef53b6030039 ("net/virtio-user: support LSC")
Cc: stable@dpdk.org
Signed-off-by: Sebastian Basierski <sebastianx.basierski@intel.com>
Acked-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
drivers/net/virtio/virtio_user_ethdev.c

index 57c964d..20b7292 100644 (file)
@@ -86,7 +86,11 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
                        int flags;
 
                        flags = fcntl(dev->vhostfd, F_GETFL);
-                       fcntl(dev->vhostfd, F_SETFL, flags | O_NONBLOCK);
+                       if (fcntl(dev->vhostfd, F_SETFL,
+                                       flags | O_NONBLOCK) == -1) {
+                               PMD_DRV_LOG(ERR, "error setting O_NONBLOCK flag");
+                               return;
+                       }
                        r = recv(dev->vhostfd, buf, 128, MSG_PEEK);
                        if (r == 0 || (r < 0 && errno != EAGAIN)) {
                                dev->status &= (~VIRTIO_NET_S_LINK_UP);