net/virtio-user: check FD flags getting failure

The function fcntl() could return errors,
the return value need to be checked.

Fixes: 6a84c37e39 ("net/virtio-user: add vhost-user adapter layer")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
This commit is contained in:
Yunjian Wang 2022-01-08 15:52:31 +08:00 committed by Chenbo Xia
parent edca47a1d9
commit 6abf10a21b

View File

@ -840,8 +840,10 @@ vhost_user_setup(struct virtio_user_dev *dev)
}
flag = fcntl(fd, F_GETFD);
if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
PMD_DRV_LOG(WARNING, "fcntl failed, %s", strerror(errno));
if (flag == -1)
PMD_DRV_LOG(WARNING, "fcntl get fd failed, %s", strerror(errno));
else if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
PMD_DRV_LOG(WARNING, "fcntl set fd failed, %s", strerror(errno));
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;