net/virtio-user: check error on clearing non block flag
authorSebastian Basierski <sebastianx.basierski@intel.com>
Tue, 14 Nov 2017 10:39:56 +0000 (11:39 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 6 Feb 2018 21:09:17 +0000 (22:09 +0100)
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: stable@dpdk.org
Signed-off-by: Sebastian Basierski <sebastianx.basierski@intel.com>
Acked-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_user_ethdev.c

index 452cdfc..2636490 100644 (file)
@@ -80,7 +80,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;
        }