Skip to content

Commit

Permalink
net/virtio-user: check FD flags getting failure
Browse files Browse the repository at this point in the history
[ upstream commit 6abf10a ]

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

Fixes: 6a84c37 ("net/virtio-user: add vhost-user adapter layer")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  • Loading branch information
wyjwang authored and bluca committed Feb 17, 2022
1 parent ac0c522 commit d8090fd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/virtio/virtio_user/vhost_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,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;
Expand Down

0 comments on commit d8090fd

Please sign in to comment.