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: [email protected]
cc: [email protected]
Signed-off-by: SebastianX Basierski <[email protected]>
Acked-by: Jianfeng Tan <[email protected]>
---
drivers/net/virtio/virtio_user_ethdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio/virtio_user_ethdev.c
b/drivers/net/virtio/virtio_user_ethdev.c
index 57c964d..20b7292 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -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);
--
2.7.4